private ServiceController GetController() { ServiceController sc = null; ServiceController[] services = ServiceController.GetServices(); for (int i = 0; i < services.Length; i++) { if (services[i].ServiceName == SERVICE_NAME) { sc = services[i]; break; } } // Log.Debug("service status: {0}", sc.Status.ToString() ); RTSPServiceStatus currentStatus = _status; if (sc == null) { currentStatus = RTSPServiceStatus.None; } else if (sc.Status == ServiceControllerStatus.Paused || sc.Status == ServiceControllerStatus.Stopped) { currentStatus = RTSPServiceStatus.Stoped; } else if (sc.Status == ServiceControllerStatus.Running || sc.Status == ServiceControllerStatus.StartPending) { currentStatus = RTSPServiceStatus.Started; } if ( currentStatus != _status ) { _status = currentStatus; if (onStatusChanged != null) { onStatusChanged( this, new RTSPServiceStatusChangedEventArg( _status ) ); } } Log.Debug("service state: ", currentStatus.ToString()); return sc; }
private void UpDateServiceStatus(RTSPServiceStatus status) { switch (status) { case RTSPServiceStatus.None: btnStartService.IsEnabled = false; btnStopService.IsEnabled = false; break; case RTSPServiceStatus.Started: btnStartService.IsEnabled = false; btnStopService.IsEnabled = true; break; case RTSPServiceStatus.Stoped: btnStartService.IsEnabled = true; btnStopService.IsEnabled = false; break; default: break; } }
public RTSPServiceStatusChangedEventArg(RTSPServiceStatus status) { Status = status; }