You've already forked linux-packaging-mono
Imported Upstream version 4.0.0~alpha1
Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
29
external/referencesource/System.Web/Util/TaskExtensions.cs
vendored
Normal file
29
external/referencesource/System.Web/Util/TaskExtensions.cs
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="TaskExtensions.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Web.Util {
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
// Contains helper methods for dealing with Tasks
|
||||
|
||||
internal static class TaskExtensions {
|
||||
|
||||
// Throws the exception that faulted a Task, similar to what 'await' would have done.
|
||||
// Useful for synchronous methods which have a Task instance they know to be already completed
|
||||
// and where they want to let the exception propagate upward.
|
||||
public static void ThrowIfFaulted(this Task task) {
|
||||
Debug.Assert(task.IsCompleted, "The Task passed to this method must be marked as completed so that this method doesn't block.");
|
||||
task.GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
// Gets a WithinCancellableCallbackTaskAwaiter from a Task.
|
||||
public static WithinCancellableCallbackTaskAwaitable WithinCancellableCallback(this Task task, HttpContext context) {
|
||||
return new WithinCancellableCallbackTaskAwaitable(context, task.GetAwaiter());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user