views:

127

answers:

4

It is really annoying.

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new mainForm()); <-- pausing visual studio breaks here.

Thanks guys.

+2  A: 

@sramey are you sure pausing always breaks on the said line? If I may hazard a guess here I think when you press the pause button you application is idle and the program is spending most of its time in the Win32 message loop abstracted by Application.Run(). Hence there is a high probability that VS breaks the execution of the main thread there.

I think pressing pause is not always the best way of debugging things. You need to make educated guesses about problem areas and set breakpoints in relevant methods (like Constructors, API calls etc)

Need more info on what you are trying to accomplish here.

SDX2000
A: 

The debugger wil only pause there if your application is in an idle state (i.e it is actually executing Application.Run).

If you really don't wont to end up there, you might try using the 'DebuggerNonUserCode' attribute on the method that calls Application.Run, but I wouldn't recommend it.

Vincent Van Den Berghe
A: 

Taking into account the previous comments, you might want to set a Breakpoint where you want your application to stop.

I usually do this by going to where I want the debugger to stop, then pressing F9. You can also click in the left-hand margin. There are other ways.

You can also configure breakpoints to stop only when a certain condition is true (such as i == 0).

Microsoft have a guide on Debugging in Visual Studio.

David Kemp
+1  A: 

[DebuggerStepThrough] on the Main function of program.cs may help.

Will