views:

115

answers:

2

I have a timer within my Windows service which is built using C# 2.0. We are in the process of designing the Exception handling. Since it is Timer runs on its own thread we would like to handle the out of memory exception. When that occurs we would like to stop the service. How can we gently stop the service when that happens on the different thread ?

A: 

Use the service control manager API to send your own service a "stop" command? That would allow your standard functionality for handling that command to be invoked.

soccerdad
A: 

OutOfMemoryException is never supposed to be "handled" by your application. You should start to troubleshoot if there is any memory leak immediately and resolve the leaks.

Lex Li