Can't set breakpoint in UI click handler
How can I get LINQPad to stop in a click handler? Setting a breakpoint on the Console.WriteLine statement in the following example does not stop execution.
void Main()
{
var runBtn = new Button("Run", Run).Dump("Click");
}
void Run(object sender = null)
{
Console.WriteLine("Try to set breakpoint here");
}
Comments
Main()
returns. The action you're attempting to step through is run well after the debugger is detached.You need to signal to LINQPad that your query is still running so it could continue to keep tabs on your program. You could do this by preventing
Main()
from returning or callUtil.KeepRunning()
to obtain an object that you can keep around which you can dispose when you're actually finished (or not dispose at all).