2
我正在使用NUnit和Resharper。當我完成一個測試時,JetBrain:Resharper進程仍在工作,當我寫出它的線程時,仍然有一些線程正在工作。我可以追查它是什麼樣的線程?我目前使用下面的代碼,但它只給我線程ID。我需要線程名稱。如何在完成測試後追蹤仍在工作的線程?
Process[] allProcs = Process.GetProcesses();
foreach (Process proc in allProcs)
{
if (proc.ProcessName.StartsWith("Jet"))
{
ProcessThreadCollection myThreads = proc.Threads;
Console.WriteLine("process: {0}, id: {1}", proc.ProcessName, proc.Id);
foreach (ProcessThread pt in myThreads)
{
Console.WriteLine(" thread: {0}", pt.Id);
Console.WriteLine(" started: {0}", pt.StartTime.ToString());
Console.WriteLine(" CPU time: {0}", pt.TotalProcessorTime);
Console.WriteLine(" priority: {0}", pt.BasePriority);
Console.WriteLine(" thread state: {0}", pt.ThreadState.ToString());
}
}
}
從代碼輸出上面:
process: JetBrains.ReSharper.TaskRunner.MSIL, id: 1884
thread: 3600
started: 27.1.2011 13.26.55
CPU time: 00:00:05.8812377
priority: 8
thread state: Running
你能更具體怎麼做,在VS2010 ? – Simon 2011-01-27 12:56:07