Troubleshooting program hangs
Some problems in the components used or in your code manifest as "hangs": The application stops responding, the method call never returns (or multiple calls on several threads), notifications no longer in, or a combination of these symptoms. Such problems are usually difficult to diagnose; they are often caused by "deadlocks" of simple, but also sometimes very complicated nature, resulting from a combination of various programming techniques and libraries.
The following procedure may help in analyzing the cause of the hang:
- Create a reproducible scenario in which the hang occurs, and write down the steps needed.
- Start the program under Visual Studio debugger (Debug -> Start Debugging) and trigger the hang. Alternatively, trigger the hang first, and then attach the Visual Studio debugger to the program (Debug -> Attach to Process). Make sure the proper code types for debugging are enabled (normally "Managed (v4.6, v4.5, v4.0)" and "Native").
- Break into the debugger using Debug -> Break All.
- Display the Threads window using Debug -> Windows -> Threads.
- In the Threads window, on each row in the table under the Location column, expand the call stack by clicking the down arrow on the left side of the column (if present).
- Right-click in the area of Threads window, and invoke the Select All command.
- Right-click in the area of Threads window, and invoke the Copy command.
- Paste the resulting into a text file and save it.
- If you have the capability to do so, analyze the contents of the file to check if the hang cause is not in your code.
- Deliver the text file to us for analysis (post on the forums, or send by email).