Exemplo n.º 1
0
        /// <summary>
        /// Wraps the specified generic task awaiter.
        /// </summary>
        public static TaskAwaiter <TResult> Wrap <TResult>(SystemCompiler.TaskAwaiter <TResult> awaiter)
        {
            // Access the generic task being awaited through reflection.
            var field       = awaiter.GetType().GetField("m_task", BindingFlags.NonPublic | BindingFlags.Instance);
            var awaitedTask = (SystemTasks.Task <TResult>)field?.GetValue(awaiter);

            return(new TaskAwaiter <TResult>(awaitedTask, ref awaiter));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Wraps the specified task awaiter.
 /// </summary>
 public static TaskAwaiter <TResult> Wrap <TResult>(SystemCompiler.TaskAwaiter <TResult> awaiter) => new TaskAwaiter <TResult>(null, awaiter);