public void StartMethodTrace(MethodTrace method) { int currentThreadID = Thread.CurrentThread.ManagedThreadId; ThreadTrace currentThreadTrace; if (threads.TryGetValue(currentThreadID, out currentThreadTrace)) { currentThreadTrace.StartMethodTrace(method); } else { ThreadTrace newThreadTrace = new ThreadTrace(currentThreadID); if (threads.TryAdd(currentThreadID, newThreadTrace)) { newThreadTrace.StartMethodTrace(method); } else { throw new Exception("Error occured while trying to add thread"); } } }
public Thread(ThreadTrace currentThreadTrace) { Id = currentThreadTrace.Id; Time = currentThreadTrace.TotalExecutionTime; Methods = Method.formMethodsArray(currentThreadTrace.Methods.ToArray()); }