System.ServiceProcess.ServiceController.Stop C# (CSharp) Method

Stop() public method

public Stop ( ) : void
return void
        public void Stop()
        {
        }

Usage Example

示例#1
1
            public static void RestartSB()
            {
                string ServiceName = "SolutionBuilder Core Service";

                ServiceController service = new ServiceController();
                service.MachineName = ".";
                service.ServiceName = ServiceName;
                string status = service.Status.ToString();
                try
                {
                    if (service.Status == ServiceControllerStatus.Running)
                    {
                        service.Stop();
                        service.WaitForStatus(ServiceControllerStatus.Stopped);
                    }
                    //Recycle App Pool
                    try
                    {
                        RecycleAppPool();
                    }
                    catch (Exception ex)
                    {
                        System.Windows.Forms.MessageBox.Show(ex.Message);
                    }
                    if (service.Status == ServiceControllerStatus.Stopped)
                    {
                        service.Start();
                        service.WaitForStatus(ServiceControllerStatus.Running);
                    }
                }
                catch (Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(ex.Message);
                }
            }
All Usage Examples Of System.ServiceProcess.ServiceController::Stop