// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Threading.Tasks;
namespace Microsoft.AspNet.Mvc
{
///
/// Utility methods for dealing with .
///
internal static class TaskHelper
{
///
/// Waits for the task to complete and throws the first faulting exception if the task is faulted.
/// It preserves the original stack trace when throwing the exception.
///
///
/// Invoking this method is equivalent to calling Wait() on the if it is not completed.
///
public static void WaitAndThrowIfFaulted(Task task)
{
task.GetAwaiter().GetResult();
}
///
/// Waits for the task to complete and throws the first faulting exception if the task is faulted.
/// It preserves the original stack trace when throwing the exception.
///
///
/// Invoking this method is equivalent to calling on the
/// if it is not completed.
///
public static TVal WaitAndThrowIfFaulted(Task task)
{
return task.GetAwaiter().GetResult();
}
}
}