/// <summary>Ends the await on the completed <see cref="Task{TResult}"/>.</summary> /// <returns>The result of the completed <see cref="Task{TResult}"/>.</returns> /// <exception cref="NullReferenceException">The awaiter was not properly initialized.</exception> /// <exception cref="InvalidOperationException">The task was not yet completed.</exception> /// <exception cref="TaskCanceledException">The task was canceled.</exception> /// <exception cref="Exception">The task completed in a <see cref="TaskStatus.Faulted"/> state.</exception> public TResult GetResult() { TaskAwaiter.ValidateEnd(_task); return(_task.Result); }
/// <summary> /// Schedules the continuation onto the <see cref="Task{TResult}"/> associated with this /// <see cref="TaskAwaiter{TResult}"/>. /// </summary> /// <param name="continuation">The action to invoke when the await operation completes.</param> /// <exception cref="ArgumentNullException"> /// If <paramref name="continuation"/> is <see langword="null"/>. /// </exception> /// <exception cref="InvalidOperationException">The awaiter was not properly initialized.</exception> /// <remarks>This method is intended for compiler user rather than use directly in code.</remarks> public void UnsafeOnCompleted(Action continuation) { TaskAwaiter.OnCompletedInternal(_task, continuation, true); }