Skip to content

Instantly share code, notes, and snippets.

@gulbanana
Created November 11, 2018 08:33
Show Gist options
  • Save gulbanana/0f59aadad47b85d9c69a871d8533ee86 to your computer and use it in GitHub Desktop.
Save gulbanana/0f59aadad47b85d9c69a871d8533ee86 to your computer and use it in GitHub Desktop.
puzzle.cs
using System;
using System.Threading.Tasks;
class Program
{
static void Main(string[] args)
{
Task throwException() => throw new Exception();
var worker = Task.Factory.StartNew(async () => await throwException());
try
{
worker.Wait();
Console.WriteLine($"Exception was swallowed. Task IsCompletedSuccessfully: {worker.IsCompletedSuccessfully}");
}
catch (Exception)
{
Console.WriteLine($"Exception was not swallowed. Task IsCompletedSuccessfully: {worker.IsCompletedSuccessfully}");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment