DateTime startTime = DateTime.Now;
DateTime stopTime = DateTime.Now;
TimeSpan duration = stopTime - startTime;
The problem is, if MyMethod has threads that execute, what often happens is that the threads start executing, then MyMethod closes, then it prints out the time, and the threads continue to execute until their done. In other words, the time that's recorded is essentially only the time without the threads' work. Is there a way to measure the execution time of a method that doesn't "stop the timer" before the threads called from that method are finished?