Results 1 to 8 of 8

Thread: [C#] Process Wait for Exit? [/C#]

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2010
    Posts
    9

    [C#] Process Wait for Exit? [/C#]

    Hey, is there a wait statement for processes like the one in this code snippet:
    Code:
            private void StopService(string serviceName, int timeoutMilliseconds)
            {
    
                using (ServiceController service = new ServiceController(serviceName))
                {
                    //service.DisplayName = ;
                    // Do not Stop the service if it is already stopped
    
                    if (service.Status == ServiceControllerStatus.Stopped)
                        return;
    
                    try
                    {
                        TimeSpan timeout = TimeSpan.FromMilliseconds(timeoutMilliseconds);
    
                        service.Stop();
                        service.WaitForStatus(ServiceControllerStatus.Stopped, timeout);
    
                    }
                    catch (Exception)
                    {
                    }
    
                }
            }
    Right at this point:
    Code:
    service.WaitForStatus(ServiceControllerStatus.Stopped, timeout);
    Is there something like that for a process?
    Thanks, in advance.
    Last edited by TomTheBeast; Mar 20th, 2011 at 09:36 PM. Reason: Changed my question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width