Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ServiceController sc = new ServiceController("Service_1");
- sc.Refresh();
- try
- {
- if (sc.Status == ServiceControllerStatus.Stopped)
- {
- sc.Start();
- }
- for (int i = 0; i < 100; ++i)
- {
- Thread.Sleep(100);
- sc.Refresh();
- if (sc.Status == ServiceControllerStatus.Running)
- {
- break;
- }
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement