public bool StartMonitoring() { Trace.TraceInformation("Enter."); if (_ServiceName == string.Empty) { Trace.TraceWarning("ServiceName has not been set."); return(false); } if (_SvcController != null) { Trace.TraceWarning("Service is already being monitored."); return(false); } lblServiceName.Text = _ServiceName; try { _SvcController = new WindowsServiceController(_ServiceName); tmrCheckService.Enabled = true; return(true); } catch (Exception ex) { Trace.TraceError("Exception:" + ex.Message + Environment.NewLine + "Stack Trace:" + ex.StackTrace); return(false); } }
public bool StopMonitoring() { Trace.TraceInformation("Enter."); if (_SvcController == null) { Trace.TraceWarning("Service is not being monitored."); return(false); } tmrCheckService.Enabled = false; _SvcController.Dispose(); _SvcController = null; return(true); }