public static ConfiguredValueTaskAwaitable EnsureCompleted(this ConfiguredValueTaskAwaitable awaitable, bool async)
        {
            if (!async)
            {
#if DEBUG
                VerifyTaskCompleted(awaitable.GetAwaiter().IsCompleted);
#endif
            }
            return(awaitable);
        }
예제 #2
0
 public ConfiguredValueTaskAwaiterWrapper GetAwaiter()
 {
     return(new(_awaitable.GetAwaiter()));
 }
예제 #3
0
 public WithCancellationValueTaskAwaiter <T> GetAwaiter() => new WithCancellationValueTaskAwaiter <T>(_awaitable.GetAwaiter(), _cancellationToken);
 public static ConfiguredValueTaskAwaitable EnsureCompleted(this ConfiguredValueTaskAwaitable task, bool async)
 {
     Debug.Assert(async || task.GetAwaiter().IsCompleted);
     return(task);
 }
예제 #5
0
 /// <summary>
 /// 结束对已完成任务的等待,并返回执行结果。
 /// </summary>
 /// <typeparam name="TResult">指定的结果类型。</typeparam>
 /// <param name="awaitable">给定的 <see cref="ConfiguredValueTaskAwaitable" />。</param>
 /// <returns>返回 <typeparamref name="TResult"/>。</returns>
 public static TResult AwaitResult <TResult>(this ConfiguredValueTaskAwaitable <TResult> awaitable)
 => awaitable.GetAwaiter().GetResult();
예제 #6
0
    => task.ConfigureAwait(false);     // .NET 默认调用 task.ConfigureAwait(true);

    #endregion


    #region ConfiguredValueTaskAwaitable

    /// <summary>
    /// 结束对已完成任务的等待。
    /// </summary>
    /// <param name="awaitable">给定的 <see cref="ConfiguredValueTaskAwaitable" />。</param>
    public static void Await(this ConfiguredValueTaskAwaitable awaitable)
    => awaitable.GetAwaiter().GetResult();