Advertisement
brunobozic

Async problem with exceptions

Apr 24th, 2021
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.25 KB | None | 0 0
  1. async Task Main()
  2. {
  3.     TaskScheduler.UnobservedTaskException += (sender, args) =>
  4.     {
  5.         Console.WriteLine("A Problem");
  6.     };
  7.     Magic();
  8.     GC.Collect();
  9. }
  10. async Task Magic()
  11. {
  12.     await Task.Delay(600);
  13.     throw new Exception();
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement