Hello,
Look into the use of the ServiceController class.
http://msdn.microsoft.com/library/de...tInstances.asp
Another way of approaching the problem is to create another thread in your
service whose job is to monitor the health of your threadWorker. If that
thread notices an error via some flag, monitoring the thread's IsAlive
property, or is signalled by the theadWorker, it can abort the threadWorker
if necessary and restart it.
Hope this helps.
--
Jeffrey Wynn
so********@nospam.net
Replace -no-spa-m with "-op-to-nl-ine" and remove the dashes
"Ciaran" <ci****@insero-technologies.com> wrote in message
news:f4*************************@posting.google.co m...
Hi All,
I have created a Windows Service. In the event of an Exception
occuring I would like to notify Windows to restart the service
as shown below:
<snip>
protected override void OnStart(string[] args)
{
ThreadStart starter = new ThreadStart(this.StartListening);
Thread threadWorker = new Thread(starter);
threadWorker.Start();
}
public void StartListening()
{
try
{
...
}
catch (Exception)
{ >> RESTART THE SERVICE <<
}
}
<snip>
I'm having no joy with this...any ideas are appreciated :o)