File tree Expand file tree Collapse file tree 2 files changed +40
-1
lines changed
src/System.Reactive/Linq/Observable
tests/Tests.System.Reactive/Tests/Linq/Observable Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -661,7 +661,11 @@ private void OnCompleted(int index)
661
661
}
662
662
else
663
663
{
664
- _subscriptions [ index ] . Dispose ( ) ;
664
+ var subscriptions = Volatile . Read ( ref _subscriptions ) ;
665
+ if ( subscriptions != null && subscriptions != Array . Empty < IDisposable > ( ) )
666
+ {
667
+ Disposable . TryDispose ( ref subscriptions [ index ] ) ;
668
+ }
665
669
}
666
670
}
667
671
}
Original file line number Diff line number Diff line change @@ -4448,6 +4448,41 @@ public void Zip_AtLeastOneThrows4()
4448
4448
4449
4449
#endregion
4450
4450
4451
+ [ Fact ]
4452
+ public void Zip2WithImmediateReturn ( )
4453
+ {
4454
+ Observable . Zip < Unit , Unit , Unit > (
4455
+ Observable . Return ( Unit . Default ) ,
4456
+ Observable . Return ( Unit . Default ) ,
4457
+ ( _ , __ ) => Unit . Default
4458
+ )
4459
+ . Subscribe ( _ => { } ) ;
4460
+ }
4461
+
4462
+ [ Fact ]
4463
+ public void Zip3WithImmediateReturn ( )
4464
+ {
4465
+ Observable . Zip < Unit , Unit , Unit , Unit > (
4466
+ Observable . Return ( Unit . Default ) ,
4467
+ Observable . Return ( Unit . Default ) ,
4468
+ Observable . Return ( Unit . Default ) ,
4469
+ ( _ , __ , ___ ) => Unit . Default
4470
+ )
4471
+ . Subscribe ( _ => { } ) ;
4472
+ }
4473
+
4474
+ [ Fact ]
4475
+ public void ZipEnumerableWithImmediateReturn ( )
4476
+ {
4477
+ Enumerable . Range ( 0 , 100 )
4478
+ . Select ( _ => Observable . Return ( Unit . Default ) )
4479
+ . Zip ( )
4480
+ . Subscribe ( _ =>
4481
+ {
4482
+
4483
+ }
4484
+ ) ;
4485
+ }
4451
4486
}
4452
4487
#pragma warning restore IDE0039 // Use local function
4453
4488
}
You can’t perform that action at this time.
0 commit comments