Advertisement
OmerMor

TryExecute

Feb 16th, 2012
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.23 KB | None | 0 0
  1. public static bool TryExecute(Action action)
  2. {
  3.     try
  4.     {
  5.         action();
  6.         return true;
  7.     }
  8.     catch (Exception ex)
  9.     {
  10.         LogException(ex);
  11.         return false;
  12.     }
  13. }
  14.  
  15. public void Usage()
  16. {
  17.     return TryExecute(() => FooBar());
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement