Dealing with Application Hangs / Deadlocks in C#

c#, deadlock, debugging, logging, multithreading

Solution

You can get the client to create a minidump from TaskManager or Process Explorer. See this article for more information.

Problem

Question: Are there any ways of logging or determining where deadlocks occur in an application provided to a client (possibly by enabling some flags in the build process)? Background: Usually when I am testing code and a deadlock occurs, I am running in Visual Studio, so I can hit debug all and find which thread is waiting and where, and I immediately know what the issue is. However, there is a certain issue which causes my application to freeze up very rarely (it is not detected in unit or integration tests). This happens on a clients machine where he is only running the executable binary. I'm interested in knowing if there are any features I can enable that can help report these issues, since it's hard to say exactly would could be the problem without a debugger.

Original source