Exemple #1
0
        public void StopTrace()
        {
            int          currentThreadID = /*get thread*/ GetThreadID();
            TracedThread existingThread  = this.GetThreadBy(currentThreadID);

            if (existingThread != null)
            {
                existingThread.StopTrace();
            }
        }
Exemple #2
0
        internal void StartTrace()
        {
            var        stackTrace = new StackTrace(skipFrames: 2);
            StackFrame stackFrame = stackTrace.GetFrame(0);
            MethodBase method     = stackFrame.GetMethod();

            TracedThread tracedThread = tracedThreads.GetOrAdd(Thread.CurrentThread.ManagedThreadId, new TracedThread());

            tracedThread += method;
        }
Exemple #3
0
        public void StartTrace()
        {
            //Get method and thread from StackTrace;
            MethodBase currentMethod = new StackTrace(1).GetFrame(0).GetMethod();
            //Console.WriteLine(currentMethod.Name);
            int          currentThreadID = /*get thread*/ GetThreadID();
            TracedThread existingThread  = this.GetThreadBy(currentThreadID);

            if (existingThread == null)
            {
                TracedThread newThread = new TracedThread(currentThreadID);
                threads.Add(currentThreadID, newThread);
                existingThread = newThread;
            }
            existingThread.StartTrace(/*with: */ currentMethod);
        }