Skip to content

Instantly share code, notes, and snippets.

@RxDave
Last active August 29, 2015 14:11
Show Gist options
  • Save RxDave/d9eba10e0d9e51a968a7 to your computer and use it in GitHub Desktop.
Save RxDave/d9eba10e0d9e51a968a7 to your computer and use it in GitHub Desktop.
CurrentThreadScheduler allows cancellation of recursive or iterative observables without concurrency.
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();
}
}
}
}
@Igorbek
Copy link

Igorbek commented Jan 8, 2015

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