473,405 Members | 2,154 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.

Terminating a service when a worker thread terminates

Hello:

I created a basic windows service that polls a db and sends emails to
our subscribers. In the onstart method I create a new thread and send
it on its way to do work. It should never end unless told to do so by
the onexit event I implemented in the worker object. However there
are the rare circumstance that the thread hits a catastrophic error
and exits the main process loop. So basically the service is now
useless. Is there a way that I can periodically check the state of
the thread in the service and take down the service normally in the
service implmentation.

Please let me know what you think,

Tim
Nov 16 '05 #1
2 1769
One common way to do this is to create another thread that acts as a "sentinal"over the first. It sole job is to monitor the health of the worker thread and inform the service of a problem

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<5e**************************@posting.google.com >

Hello:

I created a basic windows service that polls a db and sends emails to
our subscribers. In the onstart method I create a new thread and send
it on its way to do work. It should never end unless told to do so by
the onexit event I implemented in the worker object. However there
are the rare circumstance that the thread hits a catastrophic error
and exits the main process loop. So basically the service is now
useless. Is there a way that I can periodically check the state of
the thread in the service and take down the service normally in the
service implmentation.

Please let me know what you think,

Tim

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.770 / Virus Database: 517 - Release Date: 27/09/2004

[microsoft.public.dotnet.languages.csharp]
Nov 16 '05 #2
You should be able to handle any error by catching them inside your loop and
ignore/report them, and continue.

--
William Stacey, MVP

"T Conti" <tc****@hotmail.com> wrote in message
news:5e**************************@posting.google.c om...
Hello:

I created a basic windows service that polls a db and sends emails to
our subscribers. In the onstart method I create a new thread and send
it on its way to do work. It should never end unless told to do so by
the onexit event I implemented in the worker object. However there
are the rare circumstance that the thread hits a catastrophic error
and exits the main process loop. So basically the service is now
useless. Is there a way that I can periodically check the state of
the thread in the service and take down the service normally in the
service implmentation.

Please let me know what you think,

Tim


Nov 16 '05 #3

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

Similar topics

3
by: DE | last post by:
Hello, I have an app with embedded Python. Python scripts create their own threads and I need to terminate these threads at the point where the user wants to leave the application. I use...
2
by: Russ McDaniel | last post by:
Originally posted to microsoft.public.dotnet.distributed_apps with no response. Reposted here with additional thoughts. --- Hello, I'm writing a Windows service which performs some...
2
by: Drew Stoddard | last post by:
We are working in C#/Winforms and are using asynchronous client-side web service calls (the Begin... and End... methods supplied by the web reference creation). Many of these calls are contained...
6
by: Dmitri Shvetsov | last post by:
Hi All, Did somebody see the situation when the VS refuses to debug the Web Service at all? I can't catch why, the initially created Web Service can be debugged very easy but after some changes...
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 :...
2
by: Dave | last post by:
I have an application that queries SQL Server and Index Server using ADO. I'd like to have a feature where a user can cancel a long-running query. What I plan on doing is to move my query code to a...
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...
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...
6
by: Tomaz Koritnik | last post by:
I have a class that runs one of it's method in another thread. I use Thread object to do this and inside ThreadMethod I have an infinite loop: While (true) { // do something Thread.Sleep(100);...
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
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.