protected override void OnStart(string[] args) { if (runtime == null) { runtime = new RtcApplicationRuntime(); runtime.UnhandledException += Runtime_UnhandledException; } runtime.Start().Wait(); // keep the process alive wh = new ManualResetEvent(false); th = new Thread(ThreadRun); th.Start(); base.OnStart(args); }
protected override void OnStop() { if (runtime != null) { runtime.Shutdown().Wait(); runtime.Dispose(); runtime.UnhandledException -= Runtime_UnhandledException; runtime = null; } if (th != null) { wh.Set(); th.Join(); } base.OnStop(); }