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