0

Is there an existing method for Mini Profiler to inline wrap an async call?

For example, for sync code, we can just do:

var syncData = MiniProfiler.Current.Inline<Data>(() => GetData(), "GetData");

However if I have an async call like this:

var data = await GetDataAsync(cancellationToken);

we can't use MiniProfiler.Current.Invoke because it doesn't support tasks, so we need to do:

Data data;
using (MiniProfiler.Current.Step("GetDataAsync"))
{
    data = await GetDataAsync(cancellationToken);
}

I was thinking of perhaps adding an extension method for tasks so that I can just add it at the end, something like:

var data = await GetDataAsync(cancellationToken).Profiled("GetDataAsync");

but wanted to check if something like this is already being handled by the existing code, before I start reinventing the wheel.

vgru
  • 49,838
  • 16
  • 120
  • 201

0 Answers0