コード例 #1
0
ファイル: Program.cs プロジェクト: sathishreddy48/C--Samples
        public void CheckStatus(string ServiceName)
        {
            ServiceController sc = new ServiceController(ServiceName);
            var Service_ctrl     = ServiceController.GetServices().FirstOrDefault(s => s.ServiceName == ServiceName);

            //Console.WriteLine(Service_ctrl.Status);
            if (Service_ctrl != null)
            {
                if ((Service_ctrl.Status != ServiceControllerStatus.Running) && (OnServiceStatusChange != null))
                {
                    ServiceChangeStatus    serviceChangeStatus    = new ServiceChangeStatus(ServiceName, Service_ctrl.Status);
                    ServicechangeEventArgs servicechangeEventArgs = new ServicechangeEventArgs(serviceChangeStatus);
                    OnServiceStatusChange(servicechangeEventArgs);
                }
            }
            else
            {
                //Service not Available
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: sathishreddy48/C--Samples
 public ServicechangeEventArgs(ServiceChangeStatus serviceChangeStatus)
 {
     this._ServiceChangeStatus = serviceChangeStatus;
 }