Created
November 11, 2018 08:33
-
-
Save gulbanana/0f59aadad47b85d9c69a871d8533ee86 to your computer and use it in GitHub Desktop.
puzzle.cs
This file contains 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; | |
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