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

Thread management in a Windows service

I have a service written in VB.Net 2.0 that watches a folder for text
files and, when a text file is placed in the folder, moves it elsewhere
and processes it. I would like to optimize the service by putting each
document on its own worker thread.

My main question is: what would happen if a service shut-down command is
issued and there are pending threads? I am hoping that the service will
wait until all of the worker threads have terminated before shutting
down, but I fear it won't be that easy. Any suggestions -- or better,
code examples available on the web -- would be much appreciated.
--
Gregory Gadow
Jan 11 '06 #1
1 2373
I don't have a code example handy, but probably the easiest way to do work in
the background is using the new BackgroundWorker component. I believe that
when a service gets a shutdown notification, it will end up calling your
service code to do the shutdown. In here, you could either wait for the
background workers to complete, or send a cancel to them to make them
terminate.

"Gregory Gadow" wrote:
I have a service written in VB.Net 2.0 that watches a folder for text
files and, when a text file is placed in the folder, moves it elsewhere
and processes it. I would like to optimize the service by putting each
document on its own worker thread.

My main question is: what would happen if a service shut-down command is
issued and there are pending threads? I am hoping that the service will
wait until all of the worker threads have terminated before shutting
down, but I fear it won't be that easy. Any suggestions -- or better,
code examples available on the web -- would be much appreciated.
--
Gregory Gadow

Jan 11 '06 #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...
2
by: Paul Gronka | last post by:
I've got a VB.NET windows application (written in VS .NET 2003) that makes a call to WMI for retrieving the MAC Address from the client's PC. It works on 4 out of the 5 PC's tested so far. All...
2
by: Joe | last post by:
Hi Guys, Is it possible to create a disk management system using .NET entirely. What I mean by the above is having an application possibly a .NET windows service monitoring the disk, creating...
1
by: Vikram | last post by:
Thanks Jonathan for the prompt reply. We have developed a program in C#, originally a windows application, that was invoking a worker thread. The threading mechanism works fine in this case. The...
1
by: benmorganpowell | last post by:
I have a small windows service which connects to a POP3 server at defined intervals, scans the available messages, extracts the required information and inserts the data into a SQL database. I am...
1
by: lcifers | last post by:
I have an application that uses the following code to return the default printer: Dim moReturn As Management.ManagementObjectCollection Dim moSearch As Management.ManagementObjectSearcher Dim...
1
by: ValK | last post by:
Hello, I’m using a multithreaded windows service to listen a file directory and process TIF documents. For example if user drops 3 files to the directory, “fileSystemWatcher_Created”...
5
by: Primera | last post by:
I use the following method to stop the WMI service: string serviceName = "Windows Management Instrumentation" public static void stopService(string serviceName) { ServiceController services =...
5
by: Tony Gravagno | last post by:
I have a class that instantiates two Timer objects that fire at different intervals. My class can be instantiated within a Windows Form or from a Windows Service. Actions performed by one of the...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.