public static object TryCatch(Action theMethod, params object[] parameters) { try { return(theMethod.DynamicInvoke(parameters)); } catch (Exception ex) { MvLog.Write(ex); return(ex); } }
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); } } } }
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); } } }