public void stopServiceBtn_Click(object sender, System.EventArgs e) { if (service.Stopped) { RtlAwareMessageBox.Show(this, Strings.ServiceStoppedText, Strings.ServiceStoppedTitle, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0); } else { try { Cursor.Current = Cursors.WaitCursor; service.StopServiceAndWait(); OnServiceStopped(EventArgs.Empty); } catch (System.ServiceProcess.TimeoutException) { RtlAwareMessageBox.Show(this, Strings.ServiceStopTimeoutText, Strings.ServiceStopTimeoutTitle, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0); } finally { Cursor.Current = Cursors.Default; } } SetServiceStatus(); }
public void stopServiceBtn_Click(object sender, System.EventArgs e) { if (service.Stopped) { MessageBox.Show(this, "The service is already stopped.", "Service Stopped", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { try { Cursor.Current = Cursors.WaitCursor; service.StopServiceAndWait(); } catch (System.ServiceProcess.TimeoutException) { MessageBox.Show(this, "The service did not stop in a timely fashion." + "\nMake sure the service is stopped.", "Service Stop Timeout", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { Cursor.Current = Cursors.Default; } } SetServiceStatus(); }