473,395 Members | 1,386 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,395 software developers and data experts.

Windows Service Has Nothing To Do Error

June 16, 2005

I'm creating a Windows Service that will backup some statistics files
for my web application. I am having a problem when I try to start my
service, where it says something about that the service started and stopped
and sometimes this is caused by the service not having work to do. It
mentioned that the Peformance Logs & Alerts service has this problem....
What I am wanting to do is in OnStart, to create a new thread and then have
that thread continuely (with .Sleep to create intervals) process a method
that backs up my files. When I do this, I don't get the stopped/started
service message, but no code ever gets executed in the method that the
thread runs. When I just try to implement it in the OnStart method itself
and not using another thread, then I get an error about that the service
couldn't be started in a timely fashion. If I implement it in the OnStart
and not have intervals, then I get the nothing to do message.... I am
greatly confused by this and would GREATLY appreciate any help! I'm sure
that I'm doing something wrong that is very obvious, but I haven't been able
to figure out what. Basically, the code looks like:

OnStart Method

dim th as new thread(addressof Backup)
th.start

Backup Method

do while true
dim reader as new streamreader(filepath)
dim writer as new streamwriter(newfilepath)

writer.write(reader.readtoend)
writer.flush
writer.close
reader.close
th.sleep(new timespan(0,5,0))
loop

Any thoughts would be greatly appreciated! Thanks and have a great day!

--
Joseph Bittman
Microsoft Certified Application Developer

Web Site: http://71.35.110.42
Dynamic IP -- Check here for future changes
Nov 21 '05 #1
1 1784
Why are you using 'TimeSpan' in your th.Sleep?

You could just say: 'th.Sleep(500)'

When you close the StreamWriter objects they are not fully distroyed

Any chance of the rest of the code to see?

Where do you get the file/directory paths from?

Crouchie1998
BA (HONS) MCP MCSE
Nov 21 '05 #2

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

Similar topics

0
by: Ger | last post by:
Hi, I have a problem with a Windows Service that I have created accessing System.Management.dll on a W2k3 environment. The Service runs fine on an XP machine but the same Service causes an error...
0
by: Eric | last post by:
I have a Windows service that I created that simply exposes a single public function (RemoteCall). How can I access this publicly exposed method of a windows service from a windows application?...
0
by: Martijn Remmen | last post by:
I have developed a service which exposes a COM object. This service is running perfect on Windows 2000 Server and Windows 2000 Professional under the SYSTEM account. When the service is...
4
by: Keith | last post by:
I'm in the same boat as the fellow who posted this message back in August: Title : Windows Service, How does one make a service "fail" properly? Author : Ross Bennett Group :...
0
by: Jonathan G. | last post by:
I'm writing my first windows service. I have a class called 'mainprocess' whose constructor is called by the service class. Within mainprocess, I declare an instance of another class I wrote,...
5
by: Dhilip Kumar | last post by:
Hi All, I'm writing a Windows Service app using C#. I need to read some configuration settings before the service starts up. These settings will be used by the service in its operation. ...
10
by: Ger | last post by:
I am having problems using VB.Net's Management base object on a machine hosting Windows Server 2003. I am trying to set file permissions from a Windows Service. These files may be loacted on a...
4
by: tshad | last post by:
What would be a good way to check programmatically whether a service was running? We have a service that dies periodically and I need to check to see if this service is running. I know how to...
3
by: Cor Pruim | last post by:
I have a very strange problem. I have written a Windows Service with VS2003 in vb.net. This service does some calculations and after that it needs to produce some Excel reports by getting data from...
0
balabaster
by: balabaster | last post by:
Hi, I know this question has been answered before (somewhat) but I have a twist... I've written a client/server application where the server portion runs as a windows service and allows...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
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...

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.