Example #1
0
 public static object TryCatch(Action theMethod, params object[] parameters)
 {
     try
     {
         return(theMethod.DynamicInvoke(parameters));
     }
     catch (Exception ex)
     {
         MvLog.Write(ex);
         return(ex);
     }
 }
Example #2
0
 public static void ForeachTry <T>(IEnumerable <T> list, Action <T> act, Action <Exception> exceptionHandler = null)
 {
     foreach (var obj in list)
     {
         try { act(obj); }
         catch (Exception ex)
         {
             if (exceptionHandler == null)
             {
                 exceptionHandler(ex);
             }
             else
             {
                 MvLog.Write(ex);
             }
         }
     }
 }
Example #3
0
 public static void DisposeObjTry(IDisposable obj, Action <Exception> exceptionHandler = null)
 {
     try
     {
         if (obj == null)
         {
             return;
         }
         obj.Dispose();
     }
     catch (Exception ex)
     {
         if (exceptionHandler == null)
         {
             exceptionHandler(ex);
         }
         else
         {
             MvLog.Write(ex);
         }
     }
 }