How to calculate the time consumed on a block of souce code.
System.Diagnostics.Stopwatch stopWatch2= new System.Diagnostics.Stopwatch();
stopWatch2.Start();
// the code that you want to know the time being comsumed.
stopWatch2.Stop();
string resTotal = stopWatch2.Elapsed.TotalMilliseconds.ToString();