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