Beispiel #1
0
 void stopService(string serviceName, ServiceController[] services, bool notify = true)
 {
     var service = services.FirstOrDefault(s => s.ServiceName == serviceName);
     if (service == null) return;
     if (service.Status != ServiceControllerStatus.Stopped) {
         if (notify)
            Trace.TraceWarning("STOPPING CONFLICTED SERVICE " + serviceName + ". Please disable this one.");
         service.Stop();
         service.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromMilliseconds(10000));
     }
 }
Beispiel #2
0
 void startService(string serviceName, ServiceController[] services)
 {
     var service = services.FirstOrDefault(s => s.ServiceName == serviceName);
     if (service == null) return;
     if (service.Status != ServiceControllerStatus.Running) {
         service.Start();
         service.WaitForStatus(ServiceControllerStatus.Running, TimeSpan.FromMilliseconds(10000));
     }
 }