Explorar o código

AsyncEnumerable.ToObservable: Do not call IAsyncEnumerator<T>.MoveNext with an already canceled CancellationToken. This would happen whenever an IObserver<T>.OnNext would dispose its subscription within a call to OnNext. The built in AnonymousAsyncEnumerator<T> checks whether it's already disposed, however, not every user code might handle canceled tokens that gracefully. Also, the continuation of MoveNext will not scheduled anyway.

Daniel Weber %!s(int64=9) %!d(string=hai) anos
pai
achega
2d64064a5c
Modificáronse 1 ficheiros con 7 adicións e 1 borrados
  1. 7 1
      Ix.NET/Source/System.Interactive.Async/ToObservable.cs

+ 7 - 1
Ix.NET/Source/System.Interactive.Async/ToObservable.cs

@@ -202,7 +202,13 @@ namespace System.Linq
                                                  if (t.Result)
                                                  {
                                                      observer.OnNext(e.Current);
-                                                     f();
+
+                                                     if (!ctd.Token.IsCancellationRequested)
+                                                         f();
+                                                     
+                                                     //In case cancellation is requested, this could only have happened
+                                                     //by disposing the returned composite disposable (see below).
+                                                     //In that case, e will be disposed too, so there is no need to dispose e here.
                                                  }
                                                  else
                                                  {