Skip to content

Instantly share code, notes, and snippets.

@alexb5dh
Last active May 29, 2017 22:31
Show Gist options
  • Select an option

  • Save alexb5dh/45972dfba41bd43327792ae52f2d8cdd to your computer and use it in GitHub Desktop.

Select an option

Save alexb5dh/45972dfba41bd43327792ae52f2d8cdd to your computer and use it in GitHub Desktop.
using System.Threading.Tasks;
public static class TaskExtensions
{
/// <summary>
/// Synchronously awaits task throwing first exception if any instead of <see cref="System.AggregateException"/>.
/// </summary>
public static T Await<T>(this Task<T> task) => task.GetAwaiter().GetResult();
/// <summary>
/// Synchronously awaits task throwing first exception if any instead of <see cref="System.AggregateException"/>.
/// </summary>
public static void Await(this Task task) => task.GetAwaiter().GetResult();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment