Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Knowing At what point the application freezes

Tags:

c#

I am developing a WinForm multithreaded application with C#. Sometimes it happens that my application hangs, or freezes or blocks.

When this happens and I am running in DEBUG mode, is there anyway to understand at what line of code my application is currently? Since it is freezed I expect to find a point where the application is locked or blocked or whatever. Is it possible to do that someway?

When It is freezed I tried to open the CALL STACK window, but this doesn't display any info; is there some action that I might do? Some "pause and check" or whatever?

like image 815
Abruzzo Forte e Gentile Avatar asked Feb 23 '10 16:02

Abruzzo Forte e Gentile


People also ask

When an application is frozen What could be the possible solution?

Problem: An application is frozen If a program has become completely unresponsive, you can press (and hold) Ctrl+Alt+Delete (the Control, Alt, and Delete keys) on your keyboard to open the Task Manager. You can then select the unresponsive application and click End task to close it. Solution 2: Restart the computer.

What is freezing in an application?

A freeze is when a software program stops functioning and cannot perform any functions. Usually there are no error messages that display, but the program remains visible. To diagnose this problem, it is recommended that you find the dump file created by Windows.


2 Answers

You may need to open the Threads window, and change the current thread. While debugging, choose Debug->Break All, and open the Threads window. If you go through each thread, by double clicking on the thread, you should be able to investigate the call stack for each thread.

That being said, if you can run your program in VS 2010 - this gets a lot easier. In VS 2010, you can use the new Concurrency Profiler, and run your code under the Concurrency Profiler with the option to Visualize the Behavior of a multithreaded application. Once your application locks up, kill it, and let the profiler churn -

Eventually, you'll get a diagram which shows each thread in your program, and when they're locked. The callstack for each blocked thread will be shown, as well as what lock is being held (with the line of source code). This makes it very easy to track down a dead lock.

like image 182
Reed Copsey Avatar answered Oct 19 '22 12:10

Reed Copsey


When debugger is attached go to Debug menu and choose 'Break All'... Then you can examine call stacks for all thread.

like image 44
Anvaka Avatar answered Oct 19 '22 13:10

Anvaka