473,405 Members | 2,344 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 Best Practices

Hello,

I have a windows service. When the onstart fires, my app creates two
threads. The first is a processing thread and the second is a watcher that
makes sure the everything is ok with the first thread. When a problem is
detected the second (watcher) thread stops the processing thread and then
throws an exception. This exception does not stop the service like I would
think.

My question is, what is the best way for the watcher thread to shut the
service down.

Thanks,
Shawn
Mar 27 '06 #1
2 3635
Shawn,

I assume to throw an event in the worker thread that when it is catched by
the main thread, stops the whole application (including the workerthread by
telling that that is a background thread).

Just my thought,

Cor

"Shawn Meyer" <me@me.com> schreef in bericht
news:eN**************@tk2msftngp13.phx.gbl...
Hello,

I have a windows service. When the onstart fires, my app creates two
threads. The first is a processing thread and the second is a watcher
that
makes sure the everything is ok with the first thread. When a problem is
detected the second (watcher) thread stops the processing thread and then
throws an exception. This exception does not stop the service like I
would
think.

My question is, what is the best way for the watcher thread to shut the
service down.

Thanks,
Shawn

Mar 28 '06 #2
Hi Shawn,

First, you don't want an exception to shut the application down. What you
want is for an exception *handler* to shut the application down. The
difference is that the handler can shut it down gracefully. Therefore, you
can use an event in either thread that is raised when an exception occurs,
and subscribe to the event in the other thread.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

"Shawn Meyer" <me@me.com> wrote in message
news:eN**************@tk2msftngp13.phx.gbl...
Hello,

I have a windows service. When the onstart fires, my app creates two
threads. The first is a processing thread and the second is a watcher
that
makes sure the everything is ok with the first thread. When a problem is
detected the second (watcher) thread stops the processing thread and then
throws an exception. This exception does not stop the service like I
would
think.

My question is, what is the best way for the watcher thread to shut the
service down.

Thanks,
Shawn

Mar 28 '06 #3

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

Similar topics

1
by: Jake | last post by:
I have to run a scheduled task once a year. Should I build a Windows Service to do this? So basically the service would always be running and a timer would poll every minute to determine to...
2
by: cd | last post by:
Is there a specific process or permissions that must be granted to get a .NET (framework 1.4) Window Service to run properly on a Windows 2003 Server? I built a Windows Service to start two local...
4
by: Reader | last post by:
I have an application that allows a user to enter a user name, user password, and the domain or machine name. From this information I would like to verify the user account and password is valid. ...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
20
by: Moty Michaely | last post by:
Hello, Can anyone please help me finding a good way to develop a c# winforms application client for a pre-developed windows service? Should I use wse2 with tcp protocol? Bu I still have win98...
0
by: Stephajn Craig | last post by:
Has anyone had this experience yet? What I'd like to do is have a Windows Service monitoring and automating Windows Messenger on a server. I've already begun a proof of concept by creating a...
0
by: John O'Neill | last post by:
Hi I would like some advice on how best to use web service proxy classes. Lets say I have a web service with 3 methods to GetCustomer, DeleteCustomer and UpdateCustomer. In my client code I...
2
by: mma | last post by:
hello everyone, i have a solution that contains the following project types: 1. Class library contains a singleton class that handles the data access (sql server 2005). 2. Windows service....
5
by: dm3281 | last post by:
I'm really starting to hate writing services -- or trying to, anyway. Why do I need to rename my project to the service name? Why do I need to set the "ServiceName" property to my service name?...
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?
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
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
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.