Skip to content

Instantly share code, notes, and snippets.

@slodge
Created May 12, 2014 10:33
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 slodge/b88e68c96dedef494181 to your computer and use it in GitHub Desktop.
Save slodge/b88e68c96dedef494181 to your computer and use it in GitHub Desktop.
void Main()
{
var a = DoFoo().Result;
}
// Define other methods and classes here
public static async System.Threading.Tasks.Task<int> DoFoo()
{
try
{
await Foo();
}
catch (ArgumentException ex)
{
/* The exception will be caught because you've awaited the call. */
Console.WriteLine("This line gets printed!");
}
return 12;
}
public static async System.Threading.Tasks.Task Foo()
{
throw new ArgumentException("ex");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment