Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keep Secondary Threads Running While Debugging With Visual Studio

I'm making an application that will send step-over key-presses to Visual Studio to enable it to take screenshots of part of its own code being executed line-by-line.

But it seems when you hit a break-point in your code, ALL threads stop, even ones that haven't hit a break-point. Is there any way around this? Is there some way to get Visual Studio to keep other threads running when I hit a break-point? Or do I have to resort to starting a separate process?

EDIT: To clarify, when the breakpoint is hit, I need to have execution stop only on the thread that hit the breakpoint. I am not looking to have the breakpoint only activate when hit by a certain thread. In other words, I need to have part of my program keep executing while one thread is stopped at a breakpoint in the debugger.

like image 938
Newell Clark Avatar asked Feb 11 '15 23:02

Newell Clark


People also ask

How do I keep debugging in Visual Studio?

In most languages supported by Visual Studio, you can edit your code in the middle of a debugging session and continue debugging. To use this feature, click into your code with your cursor while paused in the debugger, make edits, and press F5, F10, or F11 to continue debugging.

Why it is difficult to debug multi threaded programs?

Parallel processing using many threads can greatly improve program performance, but it may also make debugging more difficult because you're tracking many threads. Multithreading can introduce new types of potential bugs.


1 Answers

Okay, it seems that whenever you hit a break-point in a process, all threads in that process halt, and there doesn't seem to be any way of overriding that behavior. The only way to do what I'm trying to do is to create a second Process, and have that Process be responsible for sending the virtual key-presses to Visual Studio, via an external API call.

Obviously you'll have to have some way of communicating between the main process and the key-pressing process. I looked around and I found that Anonymous Pipes are probably the best method for communicating between two processes running on the same machine.

like image 132
Newell Clark Avatar answered Sep 19 '22 09:09

Newell Clark