I have a button in C#:
private void button15_Click(object sender, EventArgs e)
{
StartService();
}
and I try to call the method:
public static void StartService(string serviceName, int timeoutMilliseconds)
{
ServiceController service = new ServiceController(serviceName);
try
{
TimeSpan timeout = TimeSpan.FromMilliseconds(timeoutMilliseconds);
service.Start();
service.WaitForStatus(ServiceControllerStatus.Running, timeout);
}
catch
{
// ...
}
}
But I am not sure if the call method is correct on the button
You would need to provide the parameters for startservice. At the moment, Im very doubtful this would compile.
Eg