AcUtils
A high performance abstraction layer for AccuRev
Public Member Functions | List of all members
AcUtils.AcStopWatchMarker Struct Reference

Makes the using statement available for AcStopWatch objects. Adapted from Profiling with Stopwatch by Shawn Hargreaves. More...

Collaboration diagram for AcUtils.AcStopWatchMarker:
Collaboration graph
[legend]

Public Member Functions

 AcStopWatchMarker (AcStopWatch stopwatch)
 Constructor to initialize and start the stopwatch. Implemented by calling AcStopWatch::Start. More...
 
void Dispose ()
 Calls the client's ElapsedTimeHandler at the closing brace of the using statement. Implemented by calling AcStopWatch::Stop. More...
 

Detailed Description

Makes the using statement available for AcStopWatch objects. Adapted from Profiling with Stopwatch by Shawn Hargreaves.

AcStopWatch spwatch = new AcStopWatch(log); // here the ElapsedTimeHandler is log
using (new AcStopWatchMarker(spwatch))
{
// work for which to calculate time spent
...
} <-- log method called on closing brace
private static void log(string elapsedTime)
{
Console.WriteLine($"{elapsedTime} to complete.");
}
See also
AcStopWatch::ElapsedTimeHandler delegate type

Definition at line 86 of file AcStopWatch.cs.

Constructor & Destructor Documentation

AcUtils.AcStopWatchMarker.AcStopWatchMarker ( AcStopWatch  stopwatch)
inline

Constructor to initialize and start the stopwatch. Implemented by calling AcStopWatch::Start.

Definition at line 93 of file AcStopWatch.cs.

Member Function Documentation

void AcUtils.AcStopWatchMarker.Dispose ( )
inline

Calls the client's ElapsedTimeHandler at the closing brace of the using statement. Implemented by calling AcStopWatch::Stop.

Definition at line 103 of file AcStopWatch.cs.