Not necessarily a graphics programming question, but I have a question about timing multithreaded methods in C#. Normally, to time a C# function, I would go
DateTime startTime = DateTime.Now;
MyMethod();
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?
EDIT: Rewording