Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static async Task Main(string[] args)
- {
- try
- {
- await Exception();
- }
- catch(Exception)
- {
- }
- }
- public static async Task Exception()
- {
- var longTask = LongTask();
- var shortTask = Task.Delay(3000);
- if (await Task.WhenAny(longTask, shortTask) == shortTask)
- {
- throw new ShortException();
- }
- }
- public static async Task LongTask()
- {
- await Task.Delay(6000);
- throw new LongException();
- }
- public class ShortException : Exception {}
- public class LongException : Exception {}
Advertisement
Add Comment
Please, Sign In to add comment