Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug a threadpool in Visual Studio?

I'm quite new to the multithreading environment and I'm having trouble debugging an application which makes use of a threadpool created by the elapsed event in System.Timers.timer class. I have a breakpoint set inside a method which is called each time by the elapsed event, but Visual Studio's is jumping between lines of code because it is indicating the actions of the other threads.

How do I debug through a method, from start to finish on a particular thread without Visual Studio alerting me of other threads? Can Visual Studio stop all threads and let me debug from a chosen thread?

like image 934
steeppham Avatar asked Oct 26 '22 07:10

steeppham


2 Answers

Few links

  • Parallel Diagnostic tools
  • Parallel Debugging Visual Studio 2010
  • Debugging A parallel application enter image description here
like image 134
sarat Avatar answered Nov 01 '22 10:11

sarat


It is possible to suspend other threads while debugging and let only the thread you care about run.

  • Open the Threads Window in Visual Studio (Debug -> Windows -> Threads)
  • Right click on any thread you don't want to run and select "Freeze"
  • Continue debugging.

Don't forget to unfreeze the threads when you are done debugging your particular thread.

like image 36
JaredPar Avatar answered Nov 01 '22 09:11

JaredPar