system.reactive

Use Reactive Extensions to harmonize & simplify Control.Enabled = true/false conditions?

北城余情 提交于 2019-12-25 04:09:08
问题 Is it possible, or more precisely how is it possible to use RX.Net to listen to a number and different variety of (WinForms) controls' .TextChanged/.RowsChanged/.SelectionChanged events and whenever one condition is fullfilled (ControlA.Text isn't empty, ControlB.RowsCount > 0 etc) enable that one DoSomething button. I am asking because currently we have a lengthy if/then statement in each of these events' handlers and maintaining them if the condition changes is, due to duplicate code, quite

Rx.Net : Calling multiple IObservable in SelectMany

烂漫一生 提交于 2019-12-25 02:34:14
问题 Please Note: This is continuation of the question posted earlier but the solution of interest is of a different situation. I am trying to make multiple calls to the methods that each return IObservable but the values being returned back in the SelectMany statement is a Task and hence the following Subscribe statement does not compile . This is the code snippet var myWorkList = new List<MyWork> { new MyWork(),// MyWork.Execute(data) returns IObservable new MyWork() }.ToObservable(); var

Reactive Extension Simple Example not Working with Number Generator

我是研究僧i 提交于 2019-12-25 00:14:03
问题 Trying to setup Reactive Extension for a simple example. Eg: there is random Number Generator, and anytime Number Divisible by three is spotted, "Write Hello" and Observe the Event. However it does not seem to be working. Feel free to edit line, or rewrite code to make work correctly. Its a quick two page copy into Console Program. Eventually, want number generator to work in a stream , while SeeNumber observes in a Console program for one minute. Code follows this resource: Reactive

Rx.Net: Chaining subscribers - alternative approach?

对着背影说爱祢 提交于 2019-12-24 21:59:27
问题 How can I re-write this code so that I don't have to chain Subscribers like below? Reason for asking is, this style will limit in an observable depending on another observable due to the style of the code, it can get confusing. var results = myService .GetData(accountId) // returns IObservable .Subscribe(data => { new MyWork().Execute(data) // returns IObservable .Subscribe(result => { myResults.Add(result); WriteLine($"Result Id: {result.Id}"); WriteLine($"Result Status: {result.Pass}"); });

buffer with stream size instead of number of streams reactive extension C# [duplicate]

对着背影说爱祢 提交于 2019-12-24 20:55:48
问题 This question already exists : Is there a way to hold a collection of “messages” upto size 1 MB and write the result to JSON/CSV file Closed 12 months ago . I have a Producer() which push data to a blocking collection. In Consumer() , I subscribed to the blocking collection as Observable , using System.Reactive (4.1.2). I'm using Buffer , but only able to buffer on numbers of streams. Question - Can I use buffer operator with size of streams rather than number of streams? When buffer size is

rxjs zip is not lazy?

旧时模样 提交于 2019-12-24 12:22:26
问题 I 've removed the boilerplate to get to the point // a.js // My observables from stream and event this.a = Rx.Node.fromStream(this.aStream()); this.itemSource = Rx.Observable.fromEvent(ee, 'addItem'); // Zip 'em this.itemcombo = Rx.Observable.zip(this.a, this.itemSource, function (s1, s2) { return {item: s2, a: s1.toString()}; }); // Streams the lowercase alphabet rb.prototype.aStream = function aStream() { var rs = Readable(); var c = 97; rs._read = function () { rs.push(String.fromCharCode

IScheduler.Schedule vs IScheduler.ScheduleAsync?

帅比萌擦擦* 提交于 2019-12-24 12:11:19
问题 The IScheduler interface provides public static IDisposable Schedule(this IScheduler scheduler, Action action) and public static IDisposable ScheduleAsync(this IScheduler scheduler, Func<IScheduler, CancellationToken, System.Threading.Tasks.Task<IDisposable>> action) The method description for ScheduleAsync: // Summary: // Schedules work using an asynchronous method, allowing for cooperative scheduling // in an imperative coding style. // // Parameters: // scheduler: // Scheduler to schedule

Stuck with Rx Observable SelectMany

大兔子大兔子 提交于 2019-12-24 12:04:09
问题 My goal is to download files via ftp and somehow process them asynchronously. I turn list of files to IObservable and process it using SelectMany combinator. Inside there is some manipulations to download blocked files: try to download file with number of retries and return Tuple, or in case of failure return Tuple and wrap it into Observable. Sample of "Observable retriable after delay" I have taken there and slightly modified it. Problem is that my code randomly stops after downloading

Are these two Observable Operations Equivalent?

痞子三分冷 提交于 2019-12-24 11:36:59
问题 I'm not sure why, but for some reason when using the observable that is created via concat I will always get all values that are pushed from my list (works as intended). Where as with the normal subscribe it seems that some values never make it to those who have subscribed to the observable (only in certain conditions). These are the two cases that I am using. Could anyone attempt to explain why in certain cases when subscribing to the second version not all values are received? Are they not

Reactive Extensions and parallel processing

折月煮酒 提交于 2019-12-24 07:13:04
问题 I am planning on using Rx within a project of mine at some point, and I have been researching into what I can do with Rx. My project uses TPL for processing state machine transitions in parallel (utilising all available processor cores). However, to improve performance, I want to replace the current IList<> pull mechanism with an Rx push mechanism. As I do not know very much about this technology I want to ascertain whether Rx will be compatible with pushing tokens to the parallel state