views:

75

answers:

2

In our program, you can select a document type from a list. You then click OK, or double-click the selected item, and a new document is created and shown.

Now the problem is that SOMETIMES, in release mode only, when you double-click an item, the app hangs. You can still move windows, and all is repainted fine, but there's just no response whatsoever ... When in debug mode, there's no problem at all ... Also, most of the time everything works fine ??? There is no error information shown ... all we can do is terminate the process ...

How can we find out what's causing the hang?

+2  A: 

Did you introduce some logging? You can use for instance log4net to do so. In combination with PostSharp you can quickly add some logging for all method entries/exits and see if something weired is going on.
(There is even a project called Log4PostSharp, but I never gave it a try).

tanascius
+1 for mentioning PostSharp - never knew about it! Thanks :)
tommieb75
+2  A: 

In Visual Studio, use Tools + Attach to Process and select your program. If necessary, use Debug + Windows + Threads to select a thread. Debug + Break All, look at the call stack to see where it is deadlocked.

Hans Passant
Thanks nobugz - thats it!....I have 1 main thread, and 7 worker threads.The Main thread seems to be accessing a resource (translation files) :mscorlib.dll!System.Resources.RuntimeResourceSet.GetString(string key, bool ignoreCase) + 0x12 bytes ..........The only worker thread with code seems to be waiting (on the main thread ?) [In a sleep, wait, or join] mscorlib.dll!System.Threading.WaitHandle.WaitOne(long timeout, bool exitContext) + 0x2f bytesSo does this mean the app is waiting for loading a resource ??
Run CMD
Apparently, very strange. Copy and paste the entire stack trace into your question.
Hans Passant