Example #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ValueTaskAwaiter"/> struct.
 /// </summary>
 internal ValueTaskAwaiter(ref SystemValueTask awaitedTask)
 {
     this.AwaitedTask = ValueTaskAwaiter.TryGetTask(ref awaitedTask, out Task innerTask) ?
                        innerTask : null;
     this.Awaiter = awaitedTask.GetAwaiter();
     RuntimeProvider.TryGetFromSynchronizationContext(out CoyoteRuntime runtime);
     this.Runtime = runtime;
 }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ValueTaskAwaiter"/> struct.
 /// </summary>
 private ValueTaskAwaiter(ref SystemValueTask awaitedTask, ref SystemCompiler.ValueTaskAwaiter awaiter)
 {
     this.AwaitedTask = ValueTaskAwaiter.TryGetTask(ref awaitedTask, out Task innerTask) ?
                        innerTask : null;
     this.Awaiter = awaiter;
     RuntimeProvider.TryGetFromSynchronizationContext(out CoyoteRuntime runtime);
     this.Runtime = runtime;
 }
Example #3
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));
        }