Esempio n. 1
0
 public static object TryCatch(Action theMethod, params object[] parameters)
 {
     try
     {
         return(theMethod.DynamicInvoke(parameters));
     }
     catch (Exception ex)
     {
         CtkLog.Write(ex);
         return(ex);
     }
 }
Esempio n. 2
0
 public static bool DisposeTaskTry(CtkTask task, int?millisecond = null)
 {
     try
     {
         DisposeTask(task, millisecond);
         return(true);
     }
     catch (Exception ex)
     {
         CtkLog.Warn(ex);
         return(false);
     }
 }
Esempio n. 3
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
             {
                 CtkLog.Write(ex);
             }
         }
     }
 }
Esempio n. 4
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
         {
             CtkLog.Write(ex);
         }
         return(false);
     }
 }