The Sandbox Post

Single Post Permalink

View Thread: Simple Event Timer
  • User profile image

    I wanted to write a simple event timer that I could use in my projects without cluttering my code. So I wrote this.


    Public Class TimeIt Implements IDisposable Private _startTime As Long Private _eventDescription As String Public Sub New(ByVal eventDescription As String) _eventDescription = eventDescription _startTime = Now.Ticks End Sub Public Sub
     Dispose() Implements IDisposable.Dispose Debug.WriteLine(String.Format("{0} took {1} milliseconds to complete.", _eventDescription, _ CDbl(Now.Ticks - _startTime) / CDbl(TimeSpan.TicksPerMillisecond))) End Sub End Class


    And I use it like this:


     Using ti As New TimeIt("Download and Decompress SDF") ZipService.Decompress(proxy.Build(salesID), path) End Using