Skip to content

Commit e52aa3d

Browse files
committed
Allows multiple calls to TaskAsyncEnumerable.Enumerator.Dispose without raising exception.
1 parent f6c2084 commit e52aa3d

2 files changed

Lines changed: 2 additions & 3 deletions

File tree

AsyncEnumerableExtensions/AsyncEnumerableExtensions.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<TargetFramework>netstandard1.1</TargetFramework>
55
<PackageId>CXuesong.AsyncEnumerableExtensions</PackageId>
66
<Authors>CXuesong</Authors>
7-
<Version>0.1.2</Version>
7+
<Version>0.1.3</Version>
88
<Description>Some rudimentary utilities to flavor Ix.Async. Such as asynchronous generator methods.</Description>
99
<RepositoryUrl>https://github.com/CXuesong/AsyncEnumerableExtensions</RepositoryUrl>
1010
<RepositoryType>git</RepositoryType>

AsyncEnumerableExtensions/TaskAsyncEnumerable.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ private class Enumerator : IAsyncEnumerator<T>
3737
{
3838

3939
private readonly Func<IAsyncEnumerableSink<T>, CancellationToken, Task> generator;
40-
private readonly bool acceptsCancellationToken;
4140
private Task generatorTask;
4241
private AsyncEnumerableBuffer<T> buffer;
4342
private CancellationTokenSource taskCompletionTokenSource;
@@ -48,12 +47,12 @@ public Enumerator(Func<IAsyncEnumerableSink<T>, CancellationToken, Task> generat
4847
{
4948
Debug.Assert(generator != null);
5049
this.generator = generator;
51-
this.acceptsCancellationToken = acceptsCancellationToken;
5250
}
5351

5452
/// <inheritdoc />
5553
public void Dispose()
5654
{
55+
if (generatorTask == null) return;
5756
// Notify the cancellation.
5857
if (lastCombinedCancellationTokenSource != taskCompletionTokenSource)
5958
lastCombinedCancellationTokenSource.Dispose();

0 commit comments

Comments
 (0)