[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

vb.net windows services

Posted on 2011-02-27
2
Medium Priority
?
161 Views
Last Modified: 2012-05-11
Is there anyway to control a service from code? I want to be able to stop a service based on it reading a flag from within a database. It is a multithreaded program. The threads are controlled by a db flag. Is there a way in code to tell the service to stop?
0
Comment
Question by:rutledgj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 13

Accepted Solution

by:
Rahul Agarwal earned 1000 total points
ID: 34994132
please try this code:

Private Sub StartStop()
        Dim service As ServiceController = New ServiceController("MyServiceName")
        If ((service.Status.Equals(ServiceControllerStatus.Stopped)) Or
            (service.Status.Equals(ServiceControllerStatus.StopPending))) Then
            service.Start()
        Else
            service.Stop()
        End If
    End Sub
0
 

Author Comment

by:rutledgj
ID: 34996660
Could you explain how this works? How does the service.status flag get set? Also, how does this method get called?
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question