Esempio n. 1
0
 public static object TryCatch(Action theMethod, params object[] parameters)
 {
     try
     {
         return(theMethod.DynamicInvoke(parameters));
     }
     catch (Exception ex)
     {
         MvaLog.Write(ex);
         return(ex);
     }
 }
Esempio n. 2
0
 public static bool DisposeTaskTry(MvaTask task)
 {
     try
     {
         DisposeTask(task);
         return(true);
     }
     catch (Exception ex)
     {
         MvaLog.Warn(ex);
         return(false);
     }
 }
Esempio n. 3
0
 public static bool DisposeTaskTry(Task task, int millisecond = 100)
 {
     try
     {
         DisposeTask(task, millisecond);
         return(true);
     }
     catch (Exception ex)
     {
         MvaLog.Warn(ex);
         return(false);
     }
 }
Esempio n. 4
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
             {
                 MvaLog.Write(ex);
             }
         }
     }
 }
Esempio n. 5
0
 public static bool DisposeObjTry(IDisposable obj, Action <Exception> exceptionHandler = null)
 {
     if (obj == null)
     {
         return(true);
     }
     try
     {
         DisposeObj(obj);
         return(true);
     }
     catch (Exception ex)
     {
         if (exceptionHandler != null)
         {
             exceptionHandler(ex);
         }
         else
         {
             MvaLog.Write(ex);
         }
         return(false);
     }
 }