Пример #1
0
        public void OnStart(string providerName, string activityName, int task, ref Guid activityId, ref Guid relatedActivityId, EventActivityOptions options)
        {
            if (this.m_current == null)
            {
                return;
            }
            ActivityTracker.ActivityInfo activityInfo = this.m_current.Value;
            string         str            = this.NormalizeActivityName(providerName, activityName, task);
            TplEtwProvider tplEtwProvider = TplEtwProvider.Log;

            if (tplEtwProvider.Debug)
            {
                tplEtwProvider.DebugFacilityMessage("OnStartEnter", str);
                tplEtwProvider.DebugFacilityMessage("OnStartEnterActivityState", ActivityTracker.ActivityInfo.LiveActivities(activityInfo));
            }
            if (activityInfo != null)
            {
                if (activityInfo.m_level >= 100)
                {
                    activityId        = Guid.Empty;
                    relatedActivityId = Guid.Empty;
                    if (!tplEtwProvider.Debug)
                    {
                        return;
                    }
                    tplEtwProvider.DebugFacilityMessage("OnStartRET", "Fail");
                    return;
                }
                if ((options & EventActivityOptions.Recursive) == EventActivityOptions.None && this.FindActiveActivity(str, activityInfo) != null)
                {
                    this.OnStop(providerName, activityName, task, ref activityId);
                    activityInfo = this.m_current.Value;
                }
            }
            long uniqueId = activityInfo != null?Interlocked.Increment(ref activityInfo.m_lastChildID) : Interlocked.Increment(ref ActivityTracker.m_nextId);

            relatedActivityId = activityInfo != null ? activityInfo.ActivityId : Guid.Empty;
            ActivityTracker.ActivityInfo list = new ActivityTracker.ActivityInfo(str, uniqueId, activityInfo, options);
            this.m_current.Value = list;
            activityId           = list.ActivityId;
            if (!tplEtwProvider.Debug)
            {
                return;
            }
            tplEtwProvider.DebugFacilityMessage("OnStartRetActivityState", ActivityTracker.ActivityInfo.LiveActivities(list));
            tplEtwProvider.DebugFacilityMessage1("OnStartRet", activityId.ToString(), relatedActivityId.ToString());
        }
Пример #2
0
        public void OnStop(string providerName, string activityName, int task, ref Guid activityId)
        {
            if (this.m_current == null)
            {
                return;
            }
            string         str            = this.NormalizeActivityName(providerName, activityName, task);
            TplEtwProvider tplEtwProvider = TplEtwProvider.Log;

            if (tplEtwProvider.Debug)
            {
                tplEtwProvider.DebugFacilityMessage("OnStopEnter", str);
                tplEtwProvider.DebugFacilityMessage("OnStopEnterActivityState", ActivityTracker.ActivityInfo.LiveActivities(this.m_current.Value));
            }
            ActivityTracker.ActivityInfo list;
            ActivityTracker.ActivityInfo activeActivity;
            do
            {
                ActivityTracker.ActivityInfo startLocation = this.m_current.Value;
                list           = (ActivityTracker.ActivityInfo)null;
                activeActivity = this.FindActiveActivity(str, startLocation);
                if (activeActivity == null)
                {
                    activityId = Guid.Empty;
                    if (!tplEtwProvider.Debug)
                    {
                        return;
                    }
                    tplEtwProvider.DebugFacilityMessage("OnStopRET", "Fail");
                    return;
                }
                activityId = activeActivity.ActivityId;
                ActivityTracker.ActivityInfo activityInfo = startLocation;
                while (activityInfo != activeActivity && activityInfo != null)
                {
                    if (activityInfo.m_stopped != 0)
                    {
                        activityInfo = activityInfo.m_creator;
                    }
                    else
                    {
                        if (activityInfo.CanBeOrphan())
                        {
                            if (list == null)
                            {
                                list = activityInfo;
                            }
                        }
                        else
                        {
                            activityInfo.m_stopped = 1;
                        }
                        activityInfo = activityInfo.m_creator;
                    }
                }
            }while (Interlocked.CompareExchange(ref activeActivity.m_stopped, 1, 0) != 0);
            if (list == null)
            {
                list = activeActivity.m_creator;
            }
            this.m_current.Value = list;
            if (!tplEtwProvider.Debug)
            {
                return;
            }
            tplEtwProvider.DebugFacilityMessage("OnStopRetActivityState", ActivityTracker.ActivityInfo.LiveActivities(list));
            tplEtwProvider.DebugFacilityMessage("OnStopRet", activityId.ToString());
        }
        // Token: 0x0600331A RID: 13082 RVA: 0x000C2438 File Offset: 0x000C0638
        public void OnStop(string providerName, string activityName, int task, ref Guid activityId)
        {
            if (this.m_current == null)
            {
                return;
            }
            string         text = this.NormalizeActivityName(providerName, activityName, task);
            TplEtwProvider log  = TplEtwProvider.Log;

            if (log.Debug)
            {
                log.DebugFacilityMessage("OnStopEnter", text);
                log.DebugFacilityMessage("OnStopEnterActivityState", ActivityTracker.ActivityInfo.LiveActivities(this.m_current.Value));
            }
            ActivityTracker.ActivityInfo activityInfo;
            for (;;)
            {
                ActivityTracker.ActivityInfo value = this.m_current.Value;
                activityInfo = null;
                ActivityTracker.ActivityInfo activityInfo2 = this.FindActiveActivity(text, value);
                if (activityInfo2 == null)
                {
                    break;
                }
                activityId = activityInfo2.ActivityId;
                ActivityTracker.ActivityInfo activityInfo3 = value;
                while (activityInfo3 != activityInfo2 && activityInfo3 != null)
                {
                    if (activityInfo3.m_stopped != 0)
                    {
                        activityInfo3 = activityInfo3.m_creator;
                    }
                    else
                    {
                        if (activityInfo3.CanBeOrphan())
                        {
                            if (activityInfo == null)
                            {
                                activityInfo = activityInfo3;
                            }
                        }
                        else
                        {
                            activityInfo3.m_stopped = 1;
                        }
                        activityInfo3 = activityInfo3.m_creator;
                    }
                }
                if (Interlocked.CompareExchange(ref activityInfo2.m_stopped, 1, 0) == 0)
                {
                    goto Block_9;
                }
            }
            activityId = Guid.Empty;
            if (log.Debug)
            {
                log.DebugFacilityMessage("OnStopRET", "Fail");
            }
            return;

Block_9:
            if (activityInfo == null)
            {
                ActivityTracker.ActivityInfo activityInfo2;
                activityInfo = activityInfo2.m_creator;
            }
            this.m_current.Value = activityInfo;
            if (log.Debug)
            {
                log.DebugFacilityMessage("OnStopRetActivityState", ActivityTracker.ActivityInfo.LiveActivities(activityInfo));
                log.DebugFacilityMessage("OnStopRet", activityId.ToString());
            }
        }
        // Token: 0x06003319 RID: 13081 RVA: 0x000C22B0 File Offset: 0x000C04B0
        public void OnStart(string providerName, string activityName, int task, ref Guid activityId, ref Guid relatedActivityId, EventActivityOptions options)
        {
            if (this.m_current == null)
            {
                if (this.m_checkedForEnable)
                {
                    return;
                }
                this.m_checkedForEnable = true;
                if (TplEtwProvider.Log.IsEnabled(EventLevel.Informational, (EventKeywords)128L))
                {
                    this.Enable();
                }
                if (this.m_current == null)
                {
                    return;
                }
            }
            ActivityTracker.ActivityInfo value = this.m_current.Value;
            string         text = this.NormalizeActivityName(providerName, activityName, task);
            TplEtwProvider log  = TplEtwProvider.Log;

            if (log.Debug)
            {
                log.DebugFacilityMessage("OnStartEnter", text);
                log.DebugFacilityMessage("OnStartEnterActivityState", ActivityTracker.ActivityInfo.LiveActivities(value));
            }
            if (value != null)
            {
                if (value.m_level >= 100)
                {
                    activityId        = Guid.Empty;
                    relatedActivityId = Guid.Empty;
                    if (log.Debug)
                    {
                        log.DebugFacilityMessage("OnStartRET", "Fail");
                    }
                    return;
                }
                if ((options & EventActivityOptions.Recursive) == EventActivityOptions.None)
                {
                    ActivityTracker.ActivityInfo activityInfo = this.FindActiveActivity(text, value);
                    if (activityInfo != null)
                    {
                        this.OnStop(providerName, activityName, task, ref activityId);
                        value = this.m_current.Value;
                    }
                }
            }
            long uniqueId;

            if (value == null)
            {
                uniqueId = Interlocked.Increment(ref ActivityTracker.m_nextId);
            }
            else
            {
                uniqueId = Interlocked.Increment(ref value.m_lastChildID);
            }
            relatedActivityId = EventSource.CurrentThreadActivityId;
            ActivityTracker.ActivityInfo activityInfo2 = new ActivityTracker.ActivityInfo(text, uniqueId, value, relatedActivityId, options);
            this.m_current.Value = activityInfo2;
            activityId           = activityInfo2.ActivityId;
            if (log.Debug)
            {
                log.DebugFacilityMessage("OnStartRetActivityState", ActivityTracker.ActivityInfo.LiveActivities(activityInfo2));
                log.DebugFacilityMessage1("OnStartRet", activityId.ToString(), relatedActivityId.ToString());
            }
        }