/// <summary> /// Starts TimedScopes before task execution and finish after it's completion /// </summary> public static ValueTask WithTimedScope(this Task task, ITimedScopeProvider provider, TimedScopeDefinition definition) => new ValueTask(task).WithTimedScope(provider, definition);
/// <summary> /// Starts TimedScopes before task execution and finish after it's completion /// </summary> public static async ValueTask WithTimedScope(this ValueTask task, ITimedScopeProvider provider, TimedScopeDefinition definition) => // await required to convert ValueTask<T> to ValueTask https://github.com/microsoft/Omex/pull/153#discussion_r389761929 await ConvertToTaskWithResultValue(task).WithTimedScope(provider, definition).ConfigureAwait(false);
/// <summary> /// Starts TimedScopes before task execution and finish after it's completion /// </summary> public static ValueTask <TResult> WithTimedScope <TResult>(this Task <TResult> task, ITimedScopeProvider provider, TimedScopeDefinition definition) => new ValueTask <TResult>(task).WithTimedScope(provider, definition);
/// <summary> /// Starts TimedScopes before task execution and finish after it's completion /// </summary> public static async ValueTask <TResult> WithTimedScope <TResult>(this ValueTask <TResult> task, ITimedScopeProvider provider, TimedScopeDefinition definition) { using TimedScope timedScope = provider.CreateAndStart(definition, TimedScopeResult.SystemError); TResult result = await task.ConfigureAwait(false); timedScope.SetResult(TimedScopeResult.Success); // set TimedScope result to success in case if task completed properly (without exception) return(result); }