Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TakeLast() cause runtime exception #242

Closed
luxl opened this issue Aug 9, 2024 · 2 comments
Closed

TakeLast() cause runtime exception #242

luxl opened this issue Aug 9, 2024 · 2 comments

Comments

@luxl
Copy link

luxl commented Aug 9, 2024

var status = Observable.Interval(TimeSpan.FromMilliseconds(100)).Index();
var doSomething = Observable.Interval(TimeSpan.FromMilliseconds(100)).Take(5);
status.TakeUntil(doSomething.TakeLast(1)).Subscribe(Console.WriteLine);

await Task.Delay(TimeSpan.FromDays(1));

the above code will print the following exception:

R3 UnhandleException: System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
   at System.Collections.Generic.Queue`1.Enumerator.MoveNext()
   at R3.TakeLast`1._TakeLast.OnCompletedCore(Result result)
   at R3.Observer`1.OnCompleted(Result result)

Also, keep run the programme several times, it probably print '0 1 2 3 4', but sometimes print '0 1 2 3', is this expected?

@neuecc
Copy link
Member

neuecc commented Aug 13, 2024

Thank you, I've checked the problem and fixed it.

keep run the programme several times, it probably print '0 1 2 3 4', but sometimes print '0 1 2 3', is this expected?

Since the count is taken at the same time interval, it may vary slightly due to the ThreadPool.

@neuecc
Copy link
Member

neuecc commented Aug 13, 2024

released on v1.2.5

@neuecc neuecc closed this as completed Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants