Skip to content

Instantly share code, notes, and snippets.

@jdaigle
Created November 9, 2010 23:45
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 jdaigle/670064 to your computer and use it in GitHub Desktop.
Save jdaigle/670064 to your computer and use it in GitHub Desktop.
var handleException = new Action<Exception>(e =>
{
Console.WriteLine("Handle Exception: " + e);
});
var someCodeThatThrowsAnException = new Action(() =>
{
try
{
throw new Exception("I threw an Exception!");
}
catch (Exception e)
{
handleException(e);
}
});
var result = someCodeThatThrowsAnException.BeginInvoke(null, null);
if (result.AsyncWaitHandle.WaitOne(2000))
{
// Timeout Expired
someCodeThatThrowsAnException.EndInvoke(result);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment