Last active
August 29, 2015 14:11
-
-
Save RxDave/d9eba10e0d9e51a968a7 to your computer and use it in GitHub Desktop.
CurrentThreadScheduler allows cancellation of recursive or iterative observables without concurrency.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Reactive.Concurrency; | |
using System.Reactive.Linq; | |
namespace ConsoleApplication1 | |
{ | |
class Program | |
{ | |
static void Main() | |
{ | |
using (Observable.Range(0, 100, CurrentThreadScheduler.Instance) | |
.Do(x => Console.WriteLine("Generated: {0}", x)) | |
.Take(10) | |
.Subscribe(x => Console.WriteLine("Observed: {0}", x))) | |
{ | |
Console.ReadKey(); | |
} | |
} | |
} | |
} |
Sorry, my bad. I understand the reason. Forget my question =)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try this:
it still output 10 values, so there wasn't a chance to dispose it.
I found it works due internal
Sink
usage. I couldn't implement my ownTake
without it.Can you implement
Take()
without Rx's internals?