using System.Threading.Tasks;
public static void Main()
var task = Task.Factory.StartNew(LoopAsync, TaskCreationOptions.LongRunning);
Console.WriteLine("Error");
}, TaskContinuationOptions.OnlyOnFaulted);
task.GetAwaiter().GetResult();
private static async Task LoopAsync()
Console.WriteLine("Inside the delegate");
throw new Exception("Error");