Skip to content

RecordScope

Latest
Compare
Choose a tag to compare
@LeeCampbell LeeCampbell released this 29 Sep 02:25
· 7 commits to master since this release

Adds support to record a scope of code. Leveraging the using/IDisposable pattern a scope block of code can be measured without using a Lambda/Delegate/Method.

using(recorder.RecordScope())
{
    //Code to be recorded goes here
}

This has two benefits.

  1. Avoids compiler warnings about captured variables with in lambdas for code like recorder.Record(()=>MyMethod(myLocalVariable));
  2. Allows the async/await pattern to be used e.g.
using(recorder.RecordScope())
{
    await DoAsync();
}