fork download
  1. using System;
  2. using System.Threading.Tasks;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. new Test().Entry().Wait();
  9. }
  10.  
  11. async Task Entry()
  12. {
  13. for (int i = 0; i < 5; ++i) {
  14. try {
  15. var result = Func(i);
  16. Console.WriteLine($"{i} result {result}");
  17. } catch (Exception e) {
  18. await Nothing();
  19. Console.WriteLine($"{i} caught");
  20. }
  21. }
  22. }
  23.  
  24. bool Func(int i)
  25. {
  26. if (i == 0) {
  27. throw new Exception();
  28. } else {
  29. return true;
  30. }
  31. }
  32.  
  33. async Task Nothing()
  34. {
  35. }
  36. }
  37.  
Success #stdin #stdout 0.01s 131328KB
stdin
Standard input is empty
stdout
0 caught
1 result True
1 caught
2 result True
2 caught
3 result True
3 caught
4 result True
4 caught