Periodically we get a hang on shut down of a Windows service in a production environment that we just cannot reproduce. It can be months before it happens again.
I'm putting in some diagnostics to try and help with the issue, one thing I'm looking at is adding an event to the system thread pool for 60 seconds after we initiate shut down of the application. Our application should shutdown cleanly within 10 seconds maximium.
In this event I would like to trace out the remaining running threads of the process to the event log.
I can get the running threads using System.Diagnostics.Process.GetCurrentProcess.Threads. These threads objects have native Win32 thread id's etc.
I was wondering if there was any way of getting back from these thread id's to any managed threads that they represent in the current process. The reason I am trying to do this is because for our thread pools and other threads we spawn we give the names which represent their purpose and it would really help to get these back.
Kind Regards
Noel