Selaa lähdekoodia

Improving cancellation of Range.

Bart De Smet 8 vuotta sitten
vanhempi
sitoutus
4d671dd7a5

+ 4 - 2
AsyncRx.NET/System.Reactive.Async.Linq/System/Reactive/Linq/Operators/Range.cs

@@ -43,14 +43,16 @@ namespace System.Reactive.Linq
 
             return scheduler.ScheduleAsync(async ct =>
             {
-                ct.ThrowIfCancellationRequested();
+                if (ct.IsCancellationRequested)
+                    return;
 
                 for (int i = start, end = start + count - 1; i <= end && !ct.IsCancellationRequested; i++)
                 {
                     await observer.OnNextAsync(i).RendezVous(scheduler, ct);
                 }
 
-                ct.ThrowIfCancellationRequested();
+                if (ct.IsCancellationRequested)
+                    return;
 
                 await observer.OnCompletedAsync().RendezVous(scheduler, ct);
             });