473,405 Members | 2,176 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,405 software developers and data experts.

Windows Service Written in VB will not stop properly

!NoItAll
297 100+
I have created a small windows service. It starts properly and works as expected. The only problem I am having is when I try to stop it. I get the error: "Service could not be stopped" - but it appears that the service does stop, just not right away. There isn't much code in the OnStop sub:

Expand|Select|Wrap|Line Numbers
  1.         CheckTimer.Stop()  'stops a timer that checks for a running app
  2.         EndApps()   'ends specified running applications
  3.         CheckTimer.Dispose() 'disposes of the timer completely
  4.         Logit("Stopping LCHDWatchdog Service")  'writes an exit message to the log
  5.         Threading.Thread.Sleep(1500)
  6.  
I've tried putting the sleep statement in to see if that helps, but the result is the same.

The application simply starts up and checks to see if a certain application is running (it could be multiple apps). If the apps are not running it will start them.
On close it will close the apps, then it should gracefully exit.
Any suggestions?
Jan 31 '13 #1

✓ answered by !NoItAll

Ok - found the problem. There was a type issue in the EndApps sub. I was concatenating a string in it (for a message to a log) and instead of using the ampersand I used an asterisk.
This generated only a run-time error (the IDE did not catch it) and thus the call threw an error.
So - word to the wise - double check all of the subs/functions in your services to make sure they are solid. Services don't tell you much when there is an error.

1 1448
!NoItAll
297 100+
Ok - found the problem. There was a type issue in the EndApps sub. I was concatenating a string in it (for a message to a log) and instead of using the ampersand I used an asterisk.
This generated only a run-time error (the IDE did not catch it) and thus the call threw an error.
So - word to the wise - double check all of the subs/functions in your services to make sure they are solid. Services don't tell you much when there is an error.
Jan 31 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Jan Waga | last post by:
Hello, Is there some way to control SCM timeout while starting or stopping a C# windows service? I know I can work on a different thread and quickly return from OnStart(), but I'd like my...
1
by: JDF | last post by:
I am fairly new to python and seem to have gotten ahead of myself. I am trying to write a Windows service that will return the current number of Citrix sessions to a client. This service will run...
1
by: Mr Utkal Ranjan Pradhan | last post by:
Hi Friends I want to develop a windows service application, which will open a port on the machine and constantly it will listen from that port. And when any data comes to that port I want to...
7
by: Larry Bird | last post by:
I have a windows service that want to un-install. When I run "installutil /u serivcename" I get the error that the serivce is not installed on my machine. However, when view the serivce console I...
3
by: Angshuman Agarwal | last post by:
Hello, I have written a Windows Service in VB6 and a VB Dll separately. When I call the DLL normally in VB (i.e. by adding the reference in some other form) it works fine , but if I try calling...
1
by: amirmira | last post by:
I have developed a service in VB.NET that accepts startup parameters. Everything works fine on my machine, but when I deploy the service on another machine, I get the following error when I try to...
7
by: Ahmed Perlom | last post by:
Hi all, I am trying to start a windows application that has a GUI from a Windows service written in .NET 2.0. I have been searching on this for few days now with no avail. When using the...
1
by: anushrestha | last post by:
I have a Windows Service written in C#. Memory used by the application based on the System.Environment.WorkingSet is 33MB at the begining. on average it goes up by 50MB every day. It reaches about...
0
by: rsine | last post by:
I have a windows service written in VB.Net. Periodically, the service will seemingly just stop functioning even though it is started. A simple stop and start of the service gets it going again. ...
9
by: mohitkumar | last post by:
Hello All, We have 3 windows services written in C#. We use them to process files from a folder into database and further to process the data into various SQL Tables. All the services hang...
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.