Esempio n. 1
0
        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();
            }
        }
Esempio n. 2
0
        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();
            }
        }