Last active
December 19, 2015 10:30
-
-
Save BojanKomazec/9e855ee46136afe576a5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Threading.Tasks; | |
| public class Program | |
| { | |
| public static void Main() | |
| { | |
| Program.MainAsync().Wait(); | |
| } | |
| private static async Task MainAsync() | |
| { | |
| var task = Task.Run( | |
| () => | |
| { | |
| throw new ArgumentNullException(); | |
| } | |
| ); | |
| try | |
| { | |
| await task; // (1) | |
| //task.Wait(); // (2) | |
| } | |
| catch(Exception ex) | |
| { | |
| Console.WriteLine(ex.ToString()); | |
| Console.WriteLine($"Task.Status: {task.Status}"); | |
| Console.WriteLine($"Task.IsFaulted: {task.IsFaulted}"); | |
| Console.WriteLine($"Task.Exception: {((task.Exception == null) ? "null" : task.Exception.ToString())}"); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment