Created
August 9, 2011 04:02
-
-
Save shiftkey/1133393 to your computer and use it in GitHub Desktop.
This is how you use TPL to crash your host process - don't ask me why you would use it in this way....
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
static void Main(string[] args) | |
{ | |
try | |
{ | |
var factory = new TaskFactory(); | |
var task = factory.StartNew(() => { throw new Exception(); }); | |
task.Wait(); | |
} | |
catch (Exception ex) | |
{ | |
Console.WriteLine("I have found an exception"); | |
throw ex; | |
} | |
} | |
// or to do it even simpler | |
static void Main(string[] args) | |
{ | |
var factory = new TaskFactory(); | |
var task = factory.StartNew(() => { throw new Exception(); }); | |
task.Wait(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment