Forums
New posts
Search forums
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
C# Community
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
VB.NET
Windows Services
Starting and stopping services in VB.NET
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="jmcilhinney, post: 9507, member: 641"] You should use a ServiceController component. Set the ServiceName property to bind to the desired service and use the Status property to determine whether it is running. Use the Start and Stop methods to do the obvious. You can use WaitForStatus to wait until the service has started before launching the additional app, which you would do using the Process.Start method. I'm not sure whether you mean you want the service stopped when your original app closes or the additional app you started. If it's your original, simply call Stop on the ServiceController in the Closed (or Closing, if the object has been disposed by the time of the Closed event) event handler of your main form. If you mean the additional app, you can call WaitForExit on the Process if you don't mind your original app freezing. Otherwise you would need to do periodical checks, controlled by a Timer, to see whether the Process was still running and, if not, stop the service. If the user closes your main app first, I doubt that there would be a way for you to stop the service. [/QUOTE]
Insert quotes…
Verification
Post reply
VB.NET
Windows Services
Starting and stopping services in VB.NET
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…
Top
Bottom