system.reactive

How to await finished IObserver call including observing subscriber calls?

放肆的年华 提交于 2019-12-11 19:28:20
问题 How to wait for subscribers method completion when calling onNext and the subscriber is on another thread/task? I miss something like await onNext() e.g. for Subject... For example when running on the same Thread: [Test, Explicit] public void TestSyncOnSameTask() { Console.WriteLine("Starting on threadId:{0}", Thread.CurrentThread.ManagedThreadId); using (var subject = new Subject<int>()) using (subject .Subscribe( o => Console.WriteLine("Received {1} on threadId:{0}", Thread.CurrentThread

Should we use Reactive Extension's Observable pattern to run multiple dependent async tasks? [closed]

一世执手 提交于 2019-12-11 15:14:32
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 10 months ago . I have a general question regarding designing the architecture of my cross-platform solution (Xamarin.Forms and ASP.NET Core). I have a requirement of calling multiple API endpoints (similar to a blog aggregation app) and I want to create a shared REST API wrapper library

Polly Retry with RX Observable.Interval

喜欢而已 提交于 2019-12-11 15:09:55
问题 I'm new to Polly and I'm trying to apply the Retry policy, so that I can have it manually handling the retry connection in case of IBMMQ connection issue. Please, consider the following code: public class ReconnectException : Exception { } public class QueueMonitor : IObservable<Message>, IDisposable { private readonly MQQueue mqQueue; private readonly MQQueueManager queueManager; private readonly string queueName; private IDisposable timer; private readonly object lockObj = new object();

What are the functional benefits of recursive scheduling in System.Reactive?

删除回忆录丶 提交于 2019-12-11 15:02:52
问题 I'm current reading http://www.introtorx.com/ and I'm getting really interested in stripping Subject<T> out of my reactive code. I'm starting to understand how to encapsulate sequence generation so that I can reason better about a given sequence. I read a few SO questions and ended up reading about scheduling. Of particular interest is recursive scheduling, using the Schedule(this IScheduler scheduler, Action<TState,Action<TState>>) overloads - like this one. The book is starting to show its

reactiveui whenany on dependency property

三世轮回 提交于 2019-12-11 14:36:33
问题 I have simple WPF app with two textboxes and ReactiveUI. I try to lookup for dependency property of first textbox by using WhenAny public partial class MainWindow : Window { public MainWindow() { RxApp.DeferredScheduler = DispatcherScheduler.Current; InitializeComponent(); Text1.WhenAny(i => i.Text, i => i.Value).Subscribe(_ => SomeMethod()); } void SomeMethod() { MessageBox.Show("Boom!"); } } My Form code is <Window x:Class="TestObservable.MainWindow" xmlns="http://schemas.microsoft.com

Why does TakeLast<T>() method not work on a ReplaySubject<T>

半腔热情 提交于 2019-12-11 12:15:21
问题 According the the MSDN documentation, the following code should output '5' to the console window. Instead, nothing is displayed. static void Main(string[] args) { var o = new ReplaySubject<int>(); o.OnNext(0); o.OnNext(1); o.OnNext(2); o.OnNext(3); o.OnNext(4); o.OnNext(5); o.TakeLast(1).Subscribe(Console.WriteLine); Console.WriteLine("Press any key to exit"); Console.ReadKey(); } Expected output: 5 Press any key to exit Actual output: Press any key to exit Can anyone please explain why this

What is the NO_PERF flag in reactive extensions source code doing

家住魔仙堡 提交于 2019-12-11 11:07:35
问题 In the ReactiveExtensions source code there are huge swathes of codes switching between different implementations such as https://github.com/Reactive-Extensions/Rx.NET/blob/master/Rx.NET/Source/System.Reactive.Linq/Reactive/Linq/QueryLanguage.StandardSequenceOperators.cs and a snippet #if !NO_PERF return new Distinct<TSource, TSource>(source, x => x, EqualityComparer<TSource>.Default); #else return Distinct_(source, x => x, EqualityComparer<TSource>.Default); #endif what is the intention of

Rx: What are subscriptions and how do subscriptions work?

霸气de小男生 提交于 2019-12-11 10:48:11
问题 I'm learning reactive extensions (rx) in .NET and I'm struggling a little bit with what a "subscription" really is and when it is used. Lets take some sample data, taken from this thread: using System; using System.Reactive.Linq; using System.Threading; namespace ConsoleApp1 { class Program { class Result { public bool Flag { get; set; } public string Text { get; set; } } static void Main(string[] args) { var source = Observable.Create<Result>(f => { Console.WriteLine("Start creating data!");

Observable not reacting to blocking collection changed on different thread

半世苍凉 提交于 2019-12-11 09:16:43
问题 I have the following code: class Program { static void Main(string[] args) { var watcher = new SNotifier(DumpToConsole); watcher.StartQueue(); Console.ReadLine(); } private static void DumpToConsole(IList<Timestamped<int>> currentCol) { Console.WriteLine("buffer time elapsed, current collection contents is: {0} items.", currentCol.Count); Console.WriteLine("holder has: {0}", currentCol.Count); } } the SNotifier: public class SNotifier { private BlockingCollection<int> _holderQueue; private

Creating generated sequence of events as a cold sequence

落爺英雄遲暮 提交于 2019-12-11 08:41:13
问题 FWIW - I'm scrapping the previous version of this question in favor of different one along the same way after asking for advice on meta I have a webservice that contains configuration data. I would like to call it at regular intervals Tok in order to refresh the configuration data in the application that uses it. If the service is in error (timeout, down, etc) I want to keep the data from the previous call and call the service again after a different time interval Tnotok . Finally I want the