Ejemplo n.º 1
0
        internal static void EndInternalTracking(Guid cmdletUniqueId, string groupName, string funcName)
        {
            LatencyTracker latencyTracker = CmdletLatencyTracker.GetLatencyTracker(cmdletUniqueId);

            if (latencyTracker == null)
            {
                return;
            }
            latencyTracker.EndInternalTracking(groupName, funcName);
        }
Ejemplo n.º 2
0
        internal static T ExecuteAndLog <T>(string funcName, bool missionCritical, LatencyTracker latencyTracker, ExEventLog eventLog, ExEventLog.EventTuple eventTuple, Trace tracer, ExWatson.IsExceptionInteresting isExceptionInteresting, Action <Exception> onError, T defaultReturnValue, Func <T> func)
        {
            bool flag = false;
            T    result;

            try
            {
                tracer.TraceDebug <Func <T> >(0L, "[{0}] Enter.", func);
                if (latencyTracker != null)
                {
                    flag = latencyTracker.StartInternalTracking(funcName);
                }
                result = func();
            }
            catch (Exception ex)
            {
                if (onError != null)
                {
                    onError(ex);
                }
                Diagnostics.ReportException(ex, eventLog, eventTuple, isExceptionInteresting, null, tracer, string.Format("Func {0} throws Exception {{0}}.", funcName));
                if (missionCritical)
                {
                    throw;
                }
                result = defaultReturnValue;
            }
            finally
            {
                if (flag)
                {
                    latencyTracker.EndInternalTracking(funcName);
                }
                tracer.TraceDebug <Func <T> >(0L, "[{0}] Exit.", func);
            }
            return(result);
        }