Exemple #1
0
 internal AsyncCallTracker(string calleeName, AsyncIteratorContextBase caller)
 {
     this.calleeName = calleeName;
     this.caller     = caller;
     this.activityId = AsyncHelper.Trace.ActivityId;
     this.metadata   = AsyncHelper.Trace.Metadata;
 }
Exemple #2
0
        public static void StaticTraceData(TraceEventCache eventCache, string source, TraceEventType eventType, object data)
        {
            AsyncCallTrackingTraceListener.AsyncIteratorState asyncIteratorState;
            if (source != "AsyncHelper")
            {
                return;
            }
            AsyncIteratorContextBase asyncIteratorContextBase = data as AsyncIteratorContextBase;
            TraceEventType           traceEventType           = eventType;

            if (traceEventType <= TraceEventType.Stop)
            {
                if (traceEventType == TraceEventType.Start)
                {
                    lock (AsyncCallTrackingTraceListener.iterators)
                    {
                        asyncIteratorState = new AsyncCallTrackingTraceListener.AsyncIteratorState()
                        {
                            Iterator = asyncIteratorContextBase,
                            ThreadId = eventCache.ThreadId
                        };
                        AsyncCallTrackingTraceListener.iterators.Add(asyncIteratorState.Iterator, asyncIteratorState);
                    }
                }
                else
                {
                    if (traceEventType != TraceEventType.Stop)
                    {
                        return;
                    }
                    lock (AsyncCallTrackingTraceListener.iterators)
                    {
                        AsyncCallTrackingTraceListener.iterators.Remove(asyncIteratorContextBase);
                    }
                }
            }
            else if (traceEventType == TraceEventType.Suspend)
            {
                lock (AsyncCallTrackingTraceListener.iterators)
                {
                    AsyncCallTracker asyncCallTracker = (AsyncCallTracker)data;
                    asyncIteratorState               = AsyncCallTrackingTraceListener.iterators[asyncCallTracker.Caller];
                    asyncIteratorState.Call          = asyncCallTracker;
                    asyncIteratorState.SuspendedTime = DateTime.UtcNow;
                }
            }
            else
            {
                if (traceEventType != TraceEventType.Resume)
                {
                    return;
                }
                lock (AsyncCallTrackingTraceListener.iterators)
                {
                    asyncIteratorState          = AsyncCallTrackingTraceListener.iterators[asyncIteratorContextBase];
                    asyncIteratorState.Call     = null;
                    asyncIteratorState.ThreadId = eventCache.ThreadId;
                }
            }
        }