Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to set a breakpoint in anonymous functions?

I quickly want to determine whether/when a set of events are triggered. Therefore I quickly assigned empty lambda's to them.

_session.TopologyStarted += () => { }; 

When tracing through the code when the event is triggered, the debugger goes into the anonymous function, allowing to debug it's execution. However, when setting a breakpoint on this line of code, a breakpoint is set on the assignment of the anonymous function to the event.

Is there a way to set a breakpoint within the anonymous function?

like image 531
Steven Jeuris Avatar asked Sep 06 '12 13:09

Steven Jeuris


People also ask

What allows set breakpoint?

Set breakpoints in source code To set a breakpoint in source code, click in the far left margin next to a line of code. You can also select the line and press F9, select Debug > Toggle Breakpoint, or right-click and select Breakpoint > Insert breakpoint. The breakpoint appears as a red dot in the left margin.

How do you create a breakpoint in a method?

Press F3 and then press F9 to add a breakpoint. This adds a breakpoint to the first method found using the trick.

How do you set a breakpoint or code?

An inline breakpoint can be set using Shift+F9 or through the context menu during a debug session. Inline breakpoints are shown inline in the editor. Inline breakpoints can also have conditions. Editing multiple breakpoints on a line is possible through the context menu in the editor's left margin.

What is a function breakpoint?

In software development, a breakpoint is an intentional stopping or pausing place in a program, put in place for debugging purposes. It is also sometimes simply referred to as a pause.


1 Answers

Put your cursor in the anonymous function (between the {}'s) and press F9.

like image 169
Martin Ernst Avatar answered Sep 28 '22 03:09

Martin Ernst