Reputation: 8939
I have a program which is a small Tetris like game. I have a problem with my collision detector in some configuration, I want to debug it, but the game doesn't start in the "problematic" state, I want to get the game to that state and only them to start debugging. Since the collision detector runs very often, I can't put a breakpoint at a place that I know will run only after I reach the problematic state, and the debugging process takes focus from the game window, and doesn't allow me to give input with the keyboard.
Using Visual Studio 2012, Is there a way to start the debugger only after some time, where at start it'll ignore the breakpoints, and only after I tell it, it'll start to break at the break points?
Upvotes: 3
Views: 1861
Reputation: 54178
Some variant of conditional breakpoint should work for you. The hard part is deciding when you want to break in, but conditional BPs give you a flexible framework to work within.
Upvotes: 1
Reputation: 22989
You can add a button or a shortcut and manually trigger a debugger break when you see that the game is going to enter the problematic configuration:
System.Diagnostics.Debugger.Break();
From there place another breakpoint in the collision detection procedure.
Upvotes: 2
Reputation: 67918
Yes, you can do this by starting without debugging and then when you get to the state you want, using the Debug menu, select Attach to Process. When you're presented with the list, double click your application.
Another possible solution would be to disable the breakpoints and then when you get to the state you want (in which you would have started with debugging) just enable the breakpoints you want with the Breakpoints Window.
Upvotes: 5
Reputation: 14561
//assume that frame_counter is incremented at 60 Hz
//adjust this conditional to whatever you want to trigger the breakpoint for real
if(frame_counter > 60 * 60 * 5) { //wait 5 minutes
} // place breakpoint here
Adjust to suit your needs
Upvotes: -1