views:

73

answers:

0

For some reason, after using an IpcChannel and shutting it down, sometimes the namedpipe stays open, with a thread waiting on it. I cannot make this happen on demand in a debug environment, but it happens 5 to 10 times per day in our production environment. The bad effect this is having is that it is stopping me from unloading the appdomain as there is a thread waiting infinitely on the named pipe (in a native method)...no frame on the callstack is in my code - it's an internal .net thread. If I fire up process explorer and find the named pipe handle that was left open and forcefully close it then it all becomes happy again, the appdomain unloads fine. It's possible I'm doing something wrong as I haven't worked with IpcChannels a whole lot....my server-side code is here: http://pastebin.com/f6e2583b9 if anyone wants to take a peek....this is running on fully patched Server2003/.NET 2.0.

As an ugly-ass workaround, I'm thinking I'll track every channel I create and then periodically check to make sure they shut down properly, and then on appdomain unload I'll forcefully close any pipes which are left hanging....can anyone point me in the right direction as to how I could do this? I know the name of the pipe....but I'm not sure how to check if it's still open, or how to close any existing handles...