Created
April 26, 2012 15:49
-
-
Save leegould/2500517 to your computer and use it in GitHub Desktop.
TimeThis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Diagnostics; | |
namespace NewsfeedArchiverConsole | |
{ | |
public class TimeThis : IDisposable | |
{ | |
private readonly Stopwatch timer; | |
private readonly Action<string> func; | |
private readonly string endMessage; | |
public TimeThis(Action<string> writeFunc, string startMessage, string endMessage) | |
{ | |
timer = new Stopwatch(); | |
func = writeFunc; | |
this.endMessage = endMessage; | |
func(startMessage); | |
timer.Start(); | |
} | |
#region IDisposable Members | |
public void Dispose() | |
{ | |
func(endMessage + " : " + timer.Elapsed); | |
timer.Stop(); | |
} | |
#endregion | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment