public static void Do(TraceSource trace, string name, Action action) { var operation = new TraceOperation(trace, name); try { action(); } catch (Exception e) { operation.Exception = e; throw; } finally { operation.Dispose(); } }
public static async Task <TResult> DoAsync <TResult>(TraceSource trace, string name, Func <Task <TResult> > action) { var operation = new TraceOperation(trace, name); try { return(await action()); } catch (Exception e) { operation.Exception = e; throw; } finally { operation.Dispose(); } }