Skip to content

Instantly share code, notes, and snippets.

@shiftkey
Created August 9, 2011 04:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shiftkey/1133393 to your computer and use it in GitHub Desktop.
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....
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