Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Service is stopped but process remains for a minute

I got a complex application which can run as windows service and as console app.

I mostly use the console startup for debugging. When I press Ctrl+C at the console the app stops immediatly (process ends).

When I run the app as service and select to stop it, MMC says immediatly that the service is stopped. However, the process is still running and takes about a minute to stop. I have no problem with it taking the time but I would like to have MMC wait like it does for other services. Currently I can start the service again while the old process is still running and this produces errors with exclusive resources. Also "restart" in MMC does not work because it does not wait for the process to end.

How can I make my process to wait or how do I find out which threads/processes/methods take the time?

like image 542
ZoolWay Avatar asked Apr 27 '11 08:04

ZoolWay


1 Answers

For .Net services see: How to properly stop a multi-threaded .NET windows service?

For services using WCF see also: http://msdn.microsoft.com/en-us/library/ms734781(VS.85).aspx

like image 94
Handcraftsman Avatar answered Sep 19 '22 19:09

Handcraftsman