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

  • The problem is that your program completes the moment 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 call Util.KeepRunning() to obtain an object that you can keep around which you can dispose when you're actually finished (or not dispose at all).
    void Main()
    {
      Util.KeepRunning();
      var runBtn = new Button("Run", Run).Dump("Click");
    }
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!