Chris Manuh | RE: Etch Answer 2/27/10 8:11 PM as a reply to Timothy Redekop. Suppose you're using visual studio to develop, after generating the base code for your app, open the project in visual studio and change the output type to library. Next, rewrite the generated main method so that the code to start and register of your application to the app server is in a different method from the one to stop it. Next, create a new windows service application project, and add your etch project as a reference. create an instance of your etch project from your windows service app. on service start event, you'll call the code to start and register your app to the application server. On service stop event, you'll call the code to stop your app in the app server. My restructured etch app looked like this: public class MainMyAppClient : MyAppHelper.MyAppClientFactory { private RemoteMyAppServer server = null; private ImplMyAppClient client = null;
public MainMyAppClient(string name, string uri) { server = MyAppHelper.NewServer(uri, null, this); } public void Start() { try { server._StartAndWaitUp(4000); string key = server.registerApplication("MyApp", "default", "myusername", "mypassword"); } catch (Exception ex) { } }
public void Stop() { // Disconnect from the cuae app service try { server._StopAndWaitDown(4000); } catch (Exception ex) { Logger.Error(string.Format("{0} - Stop application failed unexpected", client.ApplicationName), ex); } } public MyAppClient NewMyAppClient( RemoteMyAppServer server ) { client = new ImplMyAppClient( server ); return client; } } |
| Please sign in to flag this as inappropriate. |