I'm writing a button_click function in c#, in which i use the executeCommand to talk to a service.
ServiceController sc = new ServiceController("MyService");
int command = 145;
sc.Stop();
//writing xml file
sc.Start();
sc.ExecuteCommand(command);
At some point the program is crashing, is not able to call the executecommand because the service is in a start/stop pending status. What do i do? I need to stop/start the service because the function has to write the same xml file.