C # Change breakpoint

I enter a curious situation where I understand that if a given breakpoint on my code is then started, otherwise the method will never be called. My question is: how would I set a breakpoint on how C # code will interact with a WinForms application?

The culprit seems to be ScrollableControl.ScrollControlIntoView . I set the FlowSlayPanel AutoScroll property to true, and the vertical scrollbar is visible, but it doesn't matter anyway.

Code being called only when in debug mode, and breakpoint is hit

+4
source share
2 answers

The call stack will make it obvious. One must guess without one: yes, the debugger can certainly affect the GUI code. In particular, setting a breakpoint. This is a side effect of changing focus from your window to the main Visual Studio window. And back. This affects the code that signs the Windows "De / Activated" events, Got / LostFocus, and any code that includes drawing if VS overlaps your window.

This, of course, can interfere with debugging GUI code, which depends on these events. In extreme cases, you may need to configure the remote debugger on another machine so that focus switching is not performed during debugging.

ScrollControlIntoView () is also related. This usually happens automatically when the control gains focus. This roughly matches your question, but it's hard to see how it can be useful to solve your problem. Be sure to look at the call stack for more information.

+5
source

It depends on where exactly this code is. If in some method of processing events (for example, to resize) or, say, a drawing method, it can change the behavior of your application.

This is why a modern desktop for a programmer should have 2 monitors, where on one you run your application on another set of breakpoints. But even in this case, you may encounter some problems.

So, if a breakpoint is at previously placed locations, simple logging is often the more appropriate solution for this kind of debugging.

0
source

All Articles