Inserting Breakpoint at Runtime

  • Thread starter Thread starter Fred Chateau
  • Start date Start date
F

Fred Chateau

I need to loop through a method 599 times, then break at the 600th loop in
the debugger.

Can I do that in code?
 
Yup, conditional break :
type a boolean expression such as "i == 600" on the breakpoint (visual
studio 2005)
 
You can customize the breakpoint by right clicking on the red dot
 
I need to loop through a method 599 times, then break at the 600th loop
in
the debugger.

Can I do that in code?

You can write code that checks your loop counter and then calls
Debugger.Break(). Or you can simply set a conditional breakpoint in the
debugger, that checks the loop counter and only breaks at a specific line
when the counter matches the condition you specify.

Pete
 
Fred Chateau said:
I need to loop through a method 599 times, then break at the 600th loop in
the debugger.

Can I do that in code?

if (i == 600) global::System.Diagnostics.Debugger.Break();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top