using System.Threading.Tasks;
public static class TaskEx
public static void AvoidUn(this Task task)
task.ContinueWith(p => Console.WriteLine("Task is faulted: " + p.Exception), TaskContinuationOptions.OnlyOnFaulted);
public static async Task Main()
Console.WriteLine("Started");
TaskScheduler.UnobservedTaskException += (o, ev) => {Console.WriteLine("Unobserved handler", ev.Exception);};
Console.WriteLine("Throw exception");
throw new Exception("Test ex");
Console.WriteLine("Complete");