PDA

View Full Version : C# Threaded Execution time


Novakog
06-30-2006, 08:00 PM
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

tciny
07-02-2006, 02:31 PM
You could just wait until the threads are done... just sleep in the mean time.

CGTalk Moderation
07-02-2006, 02:31 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.