posts - 19 , comments - 8 , trackbacks - 0

October 2014 Entries

Creating an observable on a task with multiple subscribers
The following example creates an observable which wraps a task with multiple subscribers.Note that the task is cancelled when the last subscriber is disposed. using System; using System.Reactive.Linq; using System.Threading.Tasks; namespace JetBlack.Reactive.TaskExamples { class MultipleSubscribers { public void Test() { var observable = Observable.Create<int>( (observer, token) => Task.Factory.StartNew(() => { var i = 0; while (!(token.WaitHandle.WaitOne... || token.IsCancellationRequest... ......

Posted On Thursday, October 16, 2014 10:12 AM | Comments (0) | Filed Under [ C# Reactive Extensions rx Observable ]

Creating an observable on a task with cancellation logic
The following code demonstrates how to create an observable which runs a task. When the subscription is disposed the task completes. using System; using System.Reactive.Linq; using System.Threading.Tasks; namespace JetBlack.Reactive.TaskExamples { public class SingleSubscriber { public void Test() { var observable = Observable.Create<int>( (observer, token) => Task.Factory.StartNew(() => { var i = 0; while (!(token.WaitHandle.WaitOne... || token.IsCancellationRequest... observer.OnNext(i++); ......

Posted On Thursday, October 16, 2014 9:59 AM | Comments (0) | Filed Under [ C# Reactive Extensions rx Observable ]

Powered by: