473,387 Members | 1,530 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Service stopping itself

I wrote a service and installed it. After thirty seconds, an event occurs
where it checks to see if another services is running and, if it is, start
another service. After this event, I want the service to shut itself down. I
tried the End ketword but that didn't look like it worked. This is a portion
of my code: The tmrChecker object is created in the OnStart method.

If svcMSSQLServer.Status = ServiceControllerStatus.Running Then
If Not svcMailPopper.Status = ServiceControllerStatus.Running
Then

svcMailPopper.Start()
End

End If
End If

Seems strait forward enough but I was refreshing services and the service
never stopped. It remained 'started'.
I'm sure I couldn't have itself stop by calling the Stop method of itself,
right? Like:

Dim svcThisService As New ServiceController("MyNewService")
svcThisService.Stop()

That wouldn't seem right.

TIA,
Jim
Aug 27 '07 #1
1 2228
Apparently
Dim svcThisService As New ServiceController("MyNewService")
svcThisService.Stop()
Does Work.
"Jim in Arizona" <ti*******@hotmail.comwrote in message
news:Ok**************@TK2MSFTNGP02.phx.gbl...
>I wrote a service and installed it. After thirty seconds, an event occurs
where it checks to see if another services is running and, if it is, start
another service. After this event, I want the service to shut itself down.
I tried the End ketword but that didn't look like it worked. This is a
portion of my code: The tmrChecker object is created in the OnStart method.

If svcMSSQLServer.Status = ServiceControllerStatus.Running Then
If Not svcMailPopper.Status = ServiceControllerStatus.Running
Then

svcMailPopper.Start()
End

End If
End If

Seems strait forward enough but I was refreshing services and the service
never stopped. It remained 'started'.
I'm sure I couldn't have itself stop by calling the Stop method of
itself, right? Like:

Dim svcThisService As New ServiceController("MyNewService")
svcThisService.Stop()

That wouldn't seem right.

TIA,
Jim

Aug 27 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Steve Long | last post by:
In writing a Windows service with .NET, I'm noticing that the process for some services can not be killed with specifically stopping the service. If you try to kill the process with, say task...
9
by: SP | last post by:
Hi All, I wrote a windows service which is supposed to stop after specified amount of time. I am calling OnStop() after specified time. OnStop() methods executed but I dont see the service...
23
by: Adam Clauss | last post by:
I have a C# Windows Service running as the NetworkService account because it needs to access a network share. As part of the service's initialization, I want the service to terminate, if an...
2
by: Nathan | last post by:
I have created a windows service but am having difficulties handling exceptions in the OnStart. What I want to do is if an exeception occurs during any of the code executed during the OnStart is...
3
by: gregory_may | last post by:
I would like to prevent a VB.Net windows service from stopping by any user who does not have Administrative privilges on the box. Is this possible in the "OnStop" or "OnShutdown" areas of...
5
by: chris.hearson | last post by:
How do I programmatically prevent a service from stopping? I want to be able to keep my service running (started), under certain conditions, when a user tries to stop it. I have tried throwing an...
5
by: marccruz | last post by:
Hi, I am writing a Windows Service in C#. I want to gracefully fail the "protected override void OnStop()" function. To do this, I first tried throwing an Exception in the function. However,...
4
by: carson | last post by:
I have written two windows services: - service A does some crunching of local data files and uploads them to a central processing computer via http. - service B monitors a manifest file on a...
0
by: mattcfisher | last post by:
Hi, I have two windows services running together. One is the main program, and one is an "updater" wrapper for the main. The updater service starts and stops the main one (as in you should never...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.