Exemple #1
0
        /// <summary>
        /// Wraps the specified value task awaiter.
        /// </summary>
        public static ValueTaskAwaiter Wrap(SystemCompiler.ValueTaskAwaiter awaiter)
        {
            // Access the task being awaited through reflection.
            var field       = awaiter.GetType().GetField("_value", BindingFlags.NonPublic | BindingFlags.Instance);
            var awaitedTask = (ValueTask)field?.GetValue(awaiter);

            return(new ValueTaskAwaiter(ref awaitedTask, ref awaiter));
        }