Out of memory exception - Windows service stop
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 di开发者_如何转开发fferent thread ?
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.
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.
精彩评论