Пример #1
0
        public void StartTrace()
        {
            MethodBase _methodframe               = GetMethodFrame();
            int        _threadframeId             = Thread.CurrentThread.ManagedThreadId;
            ConcurrentStack <MethodTracing> stack = threadtracinglist.GetOrAdd(_threadframeId, new ConcurrentStack <MethodTracing>());
            MethodTracing methodtracing           = new MethodTracing(GetMethodName(_methodframe), GetClassNameByMethodName(_methodframe));

            stack.Push(methodtracing);
            methodtracing.StartCalculation();
        }
Пример #2
0
        public void StopTrace()
        {
            int _threadframeId = Thread.CurrentThread.ManagedThreadId;
            ConcurrentStack <MethodTracing> processingstack = null;
            ConcurrentStack <MethodTracing> finishedstack   = finishedthreads.GetOrAdd(_threadframeId, new ConcurrentStack <MethodTracing>());

            threadtracinglist.TryGetValue(_threadframeId, out processingstack);
            MethodTracing method = null;

            if (processingstack != null)
            {
                processingstack.TryPop(out method);
                method.StopCalculation();
                if (processingstack.TryPeek(out var parentmethod))
                {
                    parentmethod.AddMethod(method);
                }
                else
                {
                    finishedstack.Push(method);
                }
            }
        }
 public void AddMethod(MethodTracing method)
 {
     this.MethodsList.Add(method);
 }