Exemplo n.º 1
0
 public void Cleanup()
 {
     try
     {
         if (serviceManager != null)
         {
             serviceManager.StopServices();
             serviceManager.WaitForServicesStopped();
             serviceManager.Uninstall(threadServiceName);
             serviceManager.Uninstall(processServiceName);
             serviceManager = null;
         }
     }
     catch {}
 }
Exemplo n.º 2
0
        /// <summary>
        /// Application_End
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Application_End(Object sender, EventArgs e)
        {
            if (verbose)
            {
                Console.Error.WriteLine("Simias Process Starting Shutdown");
            }

            if (serviceManager != null)
            {
                // Send the simias down event and wait for 1/2 second for the message to be routed.
                EventPublisher eventPub = new EventPublisher();
                eventPub.RaiseEvent(new NotifyEventArgs("Simias-Down", "The simias service is terminating", DateTime.Now));
                Thread.Sleep(500);

                serviceManager.StopServices();
                serviceManager.WaitForServicesStopped();
                serviceManager = null;
            }

            if (verbose)
            {
                Console.Error.WriteLine("Simias Process Shutdown");
            }

            quit = true;
            // Exiting here immediately as delay in this exit usually means that the next process started will
            // will not get FLAIM Resources.
            if (runAsServer)
            {
                int param = 0;
                KillStrayProcesses(param);
                Console.Error.WriteLine("ALL Simias Threads are stopped,  Exiting from Simias process");
                Environment.Exit(0);
            }
        }