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

Continual Process in a Windows Service

Hello
I see that Windows Services are suppose to be able to run in their own background process. I can create simple Services based on the MSDN walkthrough, and get the OnStart/OnStop methods to work fine. But these are only triggered if the user manually goes into Component Services Manager and Starts/Stops the process - i.e. they don't continually run in the background. (Clicking either process puts the server on hold until that method finishes)

Can anyone tell me how to have a Service do a continual process in the background, such as writing a file to the c:\temp directory every 5 seconds

Thanks
Larry
Nov 18 '05 #1
2 1224
Sure. Use a Timer. The timer is initialized in the OnStart method, and you
create an event handler for the elapsed event of the timer. The event
handler will run every time the interval elapses.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Larry" <an*******@discussions.microsoft.com> wrote in message
news:FB**********************************@microsof t.com...
Hello,
I see that Windows Services are suppose to be able to run in their own background process. I can create simple Services based on the MSDN
walkthrough, and get the OnStart/OnStop methods to work fine. But these are
only triggered if the user manually goes into Component Services Manager and
Starts/Stops the process - i.e. they don't continually run in the
background. (Clicking either process puts the server on hold until that
method finishes).
Can anyone tell me how to have a Service do a continual process in the background, such as writing a file to the c:\temp directory every 5 seconds?
Thanks,
Larry

Nov 18 '05 #2
normally on onstart you start a background thread that implements the
service. when you detect onstop, you stop the thread. you can configure the
service to autostart on bootup.

-- bruce (sqlwork.com)
"Larry" <an*******@discussions.microsoft.com> wrote in message
news:FB**********************************@microsof t.com...
Hello,
I see that Windows Services are suppose to be able to run in their own background process. I can create simple Services based on the MSDN
walkthrough, and get the OnStart/OnStop methods to work fine. But these are
only triggered if the user manually goes into Component Services Manager and
Starts/Stops the process - i.e. they don't continually run in the
background. (Clicking either process puts the server on hold until that
method finishes).
Can anyone tell me how to have a Service do a continual process in the background, such as writing a file to the c:\temp directory every 5 seconds?
Thanks,
Larry

Nov 18 '05 #3

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

Similar topics

4
by: pokémon | last post by:
Ok, I want to implmement a "backgound process", but the catch is this: I want to control it via a Web Service, that is to say, the Web Service will be its API. What type of application should...
0
by: belgi | last post by:
Hi, I have a working windows service,it is looking for files on the disk and when some of the files are cupdated it calls an executable. But it takes a lot of time(about 10 minutes) to run the...
0
by: Stephan Lux | last post by:
Hi all, I have developed a windows service with Visual Basic .NET which starts a file conversion tool via the commandline. The tool open the files (z.B. Word, Excel, Acrobat...) and prints them...
3
by: belgiozen | last post by:
Hi, I have a working windows service,it is looking for files on the disk and when some of the files are cupdated it calls an executable. But it takes a lot of time(about 10 minutes) to run the...
4
by: Primo | last post by:
Hi, This problem has been frustrating me for days and I hope you experts can help me out. I am trying to run a command, which I would normally run from the command line, from within my C#...
4
by: Mrinal Kamboj | last post by:
Hi , Doubt may be bit trivial , but i wanted to know , what are the exact benefits derived while we run a background process as an NT service in windows , we can as well achieve the...
5
by: Benzi Eilon | last post by:
I have written a C# application which should run as a Windows Service. I must avoid having multiple instances of the application on one machine so I inserted the following code at the beginning of...
28
by: Jon Davis | last post by:
We're looking at running a memory-intensive process for a web site as a Windows service in isolation of IIS because IIS refuses to consume all of the available physical RAM. Considering remoting to...
4
by: Steven De Smet | last post by:
Hello, This is my first post. I searched on the internet for answers but I was unable to solve my problem. So I hope that you guy's can help me with my VB.NET problem I tried to create a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.