Calculate/Measure Total Elapsed Time for a Process in C#.Net using StopWatch


private void Totla_ElapsedTime_StopWatch()//Calculate/Measure Total Elapsed Time for a Process in C#.Net using StopWatch
        {
            System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();
            stopWatch.Start();
            System.Threading.Thread.Sleep(1000);
            stopWatch.Stop();
            // Get the elapsed time as a TimeSpan value.
            TimeSpan ts = stopWatch.Elapsed;

            // Format and display the TimeSpan value.
            string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
            ts.Hours, ts.Minutes, ts.Seconds,
            ts.Milliseconds / 10);
            string S_ElapsedTime = string.Format("Total Elapsed Time: {0}", elapsedTime);
        }