Results 1 to 8 of 8

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

  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.

  2. #2

    Thread Starter
    New Member
    Join Date
    Jan 2010
    Posts
    9

    Re: [C#] Process Controller? [/C#]

    Bump

  3. #3
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: [C#] Process Controller? [/C#]

    Quote Originally Posted by TomTheBeast View Post
    Bump
    Please do not bump threads when it has been less than 24 hours between your last post in that thread and if no one else has posted.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [C#] Process Controller? [/C#]

    As suggested, please don't bump your threads at all, never mind after less than an hour an a half. We're all volunteers here and we'll get to your question if and when we can. As long as your thread is on the first page, which it will likely be for days in the C# forum, then it is visible and there's no call for you to bump it. If it does slip off the first page, or you just feel that it hasn't been answered in a timely fashion, then you should ask yourself why and try rephrasing the question or providing some more relevant information.

    As for the question, there is a Process class that allows you to perform some management of processes.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    New Member
    Join Date
    Jan 2010
    Posts
    9

    Re: [C#] Process Controller? [/C#]

    Alright, im sorry, but thats sorta what my question is, since there is a process management class, how would i use it?

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [C#] Process Controller? [/C#]

    Quote Originally Posted by TomTheBeast View Post
    Alright, im sorry, but thats sorta what my question is, since there is a process management class, how would i use it?
    You would start by reading the documentation and finding out what members it has and what each can do. If you're not sure exactly how to proceed then, at least you'll have a better idea of what specific questions to ask.

    That said, if I remember correctly, I posted to the VB.NET CodeBank forum some code for ending processes. You can follow the CodeBank link in my signature to check that out.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    New Member
    Join Date
    Jan 2010
    Posts
    9

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

    Changed the question, i figured my old one out, and instead of making a new post, i just changed this one.

  8. #8

    Thread Starter
    New Member
    Join Date
    Jan 2010
    Posts
    9

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

    Bump, i don't see it on the first page.

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