I want to time total runtime of a progam I am working on.
Currently the code looks similar to this (sw is a member of the program class):
void Main(string[] args)
{
sw.Start();
//Code here starts a thread
//Code here joins the thread
//Code operates on results of threaded operation
sw.Stop();
Console.WrtieLine("Operation took {0}", sw.Elapsed.ToString());
}
I assume this issue is caused by the thread taking control of the program execution but that's the operation that takes the most time and I'm supposed to avoid changing that code as other projects depend on it as well.
For reference, simple observation shows that the code takes nearly half an hour to run, but the elapsed time according to the stopwatch is only 23 seconds or so. Exact output Operation took 00:00:23.1064841