diff options
author | Stephen Toub <stoub@microsoft.com> | 2018-10-25 21:19:26 -0700 |
---|---|---|
committer | Stephen Toub <stoub@microsoft.com> | 2018-10-25 21:28:04 -0700 |
commit | 9e16ad51dd0f5e77b2dbaa6300dc2da1aafe21f3 (patch) | |
tree | 4bc3f9fe9c599864eb12f9615c6566f0254a1ecc /src/System.Private.CoreLib/shared/System/Threading/Tasks | |
parent | 66fd31294f2bb0bc330a33436d8b48003689020b (diff) | |
download | coreclr-9e16ad51dd0f5e77b2dbaa6300dc2da1aafe21f3.tar.gz coreclr-9e16ad51dd0f5e77b2dbaa6300dc2da1aafe21f3.tar.bz2 coreclr-9e16ad51dd0f5e77b2dbaa6300dc2da1aafe21f3.zip |
Add ConfigureAwait extension method for IAsyncEnumerable
Diffstat (limited to 'src/System.Private.CoreLib/shared/System/Threading/Tasks')
-rw-r--r-- | src/System.Private.CoreLib/shared/System/Threading/Tasks/TaskExtensions.cs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Threading/Tasks/TaskExtensions.cs b/src/System.Private.CoreLib/shared/System/Threading/Tasks/TaskExtensions.cs index 97f2013d79..a07033dfee 100644 --- a/src/System.Private.CoreLib/shared/System/Threading/Tasks/TaskExtensions.cs +++ b/src/System.Private.CoreLib/shared/System/Threading/Tasks/TaskExtensions.cs @@ -2,6 +2,9 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System.Collections.Generic; +using System.Runtime.CompilerServices; + namespace System.Threading.Tasks { /// <summary>Provides a set of static methods for working with specific kinds of <see cref="Task"/> instances.</summary> @@ -44,5 +47,14 @@ namespace System.Threading.Tasks task.Result ?? Task.FromCanceled<TResult>(new CancellationToken(true)); } + + /// <summary>Configures how awaits on the tasks returned from an async iteration will be performed.</summary> + /// <typeparam name="T">The type of the objects being iterated.</typeparam> + /// <param name="source">The source enumerable being iterated.</param> + /// <param name="continueOnCapturedContext">Whether to capture and marshal back to the current context.</param> + /// <returns>The configured enumerable.</returns> + public static ConfiguredAsyncEnumerable<T> ConfigureAwait<T>( + this IAsyncEnumerable<T> source, bool continueOnCapturedContext) => + new ConfiguredAsyncEnumerable<T>(source, continueOnCapturedContext); } } |