using System.Threading.Tasks;
public class ReturningTaskDirectly
public async Task MrThrowExceptions()
throw new Exception("I threw an exception!");
public async Task RunWithAwait()
Console.WriteLine("Running With Await");
await Task.Run(async () =>
await MrThrowExceptions();
Console.WriteLine("Exception Caught:");
Console.WriteLine($"It said: {ex.Message}");
public Task RunWithOutAwait()
Console.WriteLine("Running Without Await");
return Task.Run(() => MrThrowExceptions());
public Task RunWithOutAwaitNoErrors()
return Task.Run(() => Console.WriteLine("I'm Just returning an async, this is fine"));
public async Task DoStuff()
await RunWithOutAwaitNoErrors();
Console.WriteLine($"DoStuff Caught Exception: {ex.Message}");
public static async Task Main()
var derp = new ReturningTaskDirectly();