reactive: ToTask doesn't unsubscribe properly
This issue occurs in a combination of an async method with Concat
, Take(1)
and with ToTask
at the end.
Rx version: 4.1.2
Observable setup:
Func<Task> asyncMethod = async () =>
{
await Task.Delay(500);
Console.WriteLine("Done");
};
var observable = Observable.Interval(TimeSpan.FromMilliseconds(200))
.Do(i => Console.WriteLine(i))
.Select(_ => Observable.FromAsync(asyncMethod))
.Concat()
.Take(1)
.Finally(() => Console.WriteLine("Finished"));
Subscribe
produces the expected result:
observable.Subscribe();
// Output:
0
1
2
Done
Finished
The task returned by ToTask
completes correctly after 1st item when using await
but the Interval
keeps emitting values:
await observable.ToTask();
// Output:
0
1
2
Done
3
4
5
... and so on
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 19
I guess it’s very much related to https://github.com/dotnet/reactive/issues/456. I can get into this tomorrow.