Another useful class

I am probably the last person to discover this but only today I discovered the Stopwatch type in the System.Diagnostics namespace. Real nice when you want to determine how long a certain action took [:)]
Stopwatch timer = Stopwatch.StartNew();
// Do some stuff you want to time.
Use the Stopwatch.IsHighResolution to check if the timer is using high resolution of not.

2 thoughts on “Another useful class

  1. here is how to format elapsed in hh:mm:ss:mmm

    Dim ts As TimeSpan = timer.Elapsed
    Dim timeElapsed As String = String.Format(“{0:00}:{1:00}:{2:00}.{3:00}”, _
    ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10)

Leave a Reply

Your email address will not be published. Required fields are marked *