diff options
author | Stephen Toub <stoub@microsoft.com> | 2018-12-07 13:56:32 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-07 13:56:32 -0500 |
commit | 811e34bc945ca1e294d64320cd3aba7866f8aeee (patch) | |
tree | cd8632d7a4c556f582b1da8ac981289871d77801 | |
parent | 372f18e8befffe3f4f1ccb3c21aeaf41af2aa763 (diff) | |
download | coreclr-811e34bc945ca1e294d64320cd3aba7866f8aeee.tar.gz coreclr-811e34bc945ca1e294d64320cd3aba7866f8aeee.tar.bz2 coreclr-811e34bc945ca1e294d64320cd3aba7866f8aeee.zip |
Add CancellationToken parameter to GetAsyncEnumerator (#21397)
-rw-r--r-- | src/System.Private.CoreLib/shared/System/Collections/Generic/IAsyncEnumerable.cs | 5 | ||||
-rw-r--r-- | src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/ConfiguredAsyncEnumerable.cs | 5 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Collections/Generic/IAsyncEnumerable.cs b/src/System.Private.CoreLib/shared/System/Collections/Generic/IAsyncEnumerable.cs index ef02070151..302b964855 100644 --- a/src/System.Private.CoreLib/shared/System/Collections/Generic/IAsyncEnumerable.cs +++ b/src/System.Private.CoreLib/shared/System/Collections/Generic/IAsyncEnumerable.cs @@ -2,6 +2,8 @@ // 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.Threading; + namespace System.Collections.Generic { /// <summary>Exposes an enumerator that provides asynchronous iteration over values of a specified type.</summary> @@ -9,7 +11,8 @@ namespace System.Collections.Generic public interface IAsyncEnumerable<out T> { /// <summary>Returns an enumerator that iterates asynchronously through the collection.</summary> + /// <param name="cancellationToken">A <see cref="CancellationToken"/> that may be used to cancel the asynchronous iteration.</param> /// <returns>An enumerator that can be used to iterate asynchronously through the collection.</returns> - IAsyncEnumerator<T> GetAsyncEnumerator(); + IAsyncEnumerator<T> GetAsyncEnumerator(CancellationToken cancellationToken = default); } } diff --git a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/ConfiguredAsyncEnumerable.cs b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/ConfiguredAsyncEnumerable.cs index 57fd481b79..25470656e5 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/ConfiguredAsyncEnumerable.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/ConfiguredAsyncEnumerable.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Runtime.InteropServices; +using System.Threading; using System.Threading.Tasks; using System.Threading.Tasks.Sources; @@ -21,8 +22,8 @@ namespace System.Runtime.CompilerServices _continueOnCapturedContext = continueOnCapturedContext; } - public Enumerator GetAsyncEnumerator() => - new Enumerator(_enumerable.GetAsyncEnumerator(), _continueOnCapturedContext); + public Enumerator GetAsyncEnumerator(CancellationToken cancellationToken = default) => + new Enumerator(_enumerable.GetAsyncEnumerator(cancellationToken), _continueOnCapturedContext); public readonly struct Enumerator { |