Skip to content

Instantly share code, notes, and snippets.

@cammerman
Created August 15, 2011 19:45
Show Gist options
  • Save cammerman/1147603 to your computer and use it in GitHub Desktop.
Save cammerman/1147603 to your computer and use it in GitHub Desktop.
OnErrorResumeNext in .NET
void IgnoreException(Action operation)
{
try { operation(); }
catch (Exception) { }
}
void OnErrorResumeNext(List<Action> operations)
{
operations.ForEach(op => IgnoreException(op));
}
void Example()
{
var operations =
new List<Action> {
() => { /* Step 1 */ },
() => { /* Step 2 */ },
() => { /* Step 3 */ },
() => { /* Step 4 */ },
() => { /* Step 5 */ },
() => { /* Step 6 */ } };
OnErrorResumeNext(operations);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment