Created
August 15, 2011 19:45
-
-
Save cammerman/1147603 to your computer and use it in GitHub Desktop.
OnErrorResumeNext in .NET
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
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