public static object TryCatch(Action theMethod, params object[] parameters) { try { return(theMethod.DynamicInvoke(parameters)); } catch (Exception ex) { MvaLog.Write(ex); return(ex); } }
public static bool DisposeTaskTry(MvaTask task) { try { DisposeTask(task); return(true); } catch (Exception ex) { MvaLog.Warn(ex); return(false); } }
public static bool DisposeTaskTry(Task task, int millisecond = 100) { try { DisposeTask(task, millisecond); return(true); } catch (Exception ex) { MvaLog.Warn(ex); return(false); } }
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); } } } }
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); } }