You've already forked linux-packaging-mono
Imported Upstream version 4.6.0.125
Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
parent
a569aebcfd
commit
e79aa3c0ed
29
mcs/class/referencesource/System.Web/Util/TaskExtensions.cs
Normal file
29
mcs/class/referencesource/System.Web/Util/TaskExtensions.cs
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