Created
October 6, 2021 11:17
-
-
Save thebirk/680eb541cd0682cbd7fbc71bb3e5230e to your computer and use it in GitHub Desktop.
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
public class DisposableStopwatch : Stopwatch, IDisposable | |
{ | |
public delegate string OnStopDelegate(TimeSpan time); | |
private readonly OnStopDelegate _onStop; | |
public DisposableStopwatch(OnStopDelegate onStop) | |
{ | |
_onStop = onStop; | |
Start(); | |
} | |
public void Dispose() | |
{ | |
Stop(); | |
Debug.WriteLine(_onStop(Elapsed)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment