Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Breakpoint "skipped" when debugging async code

I have some code that is returning the following exception ...

Object reference not set to an instance of an object

I am trying to delve in further to get to the cause, but when I set a break-point after the calling code the break-point seems to get passed by ..

PaymentProcessor pp = new PaymentProcessor();
List<string> results = await pp.ProcessPayment();
foreach (string result in results)  // Break-point set here
{
   ...
}

I wanted to see if the result of the method call returned any results. I think it has to do with the method making use of async await. If the break-point is being skipped because of the async method how do I stop it? I use the async code to free up the UI thread.

More details ....

The code where the exception bubbles up is ..

var paymentTask = GetPaymentUpdates();
paymentTask.Wait(); // Object not set exception occurs here.
like image 972
webworm Avatar asked Oct 12 '25 16:10

webworm


1 Answers

That code would be skipped is if the exception was being thrown in the ProcessPayment method and thus it never reaches that code.

like image 102
John Koerner Avatar answered Oct 14 '25 11:10

John Koerner