Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Blazor serverside - why is exception not thrown when in task ? How to avoid this ? It just freezes the app in debug

$
0
0

In my Blazor server app, I have the famous 'counter' page / button

private void IncrementCount(){    currentCount++;    throw new Exception("test");}

This is ok - exception is thrown.

If I change it to this:

private Task IncrementCount(){     currentCount++;     throw new Exception("test");}

it is also ok / exception is thrown.

But if I change it to this code:

private async Task IncrementCount(){      currentCount++;      throw new Exception("test");}

then it freezes the app and it is not responding to clicks / no exception is thrown in Visual Studio.

Is it some .NET debugger bug? (in prod exception is visible in console etc)

How to avoid this? How to force debugger to throw exception in this case also?

Thanks and regards


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>