system.reactive

Reactive Extensions Timeout that doesn't stop sequence?

…衆ロ難τιáo~ 提交于 2019-12-23 10:11:46
问题 I'm trying to make an IObservable<bool> that returns true if a UDP Message has been received in the last 5 seconds and if a timeout occurs, a false is returned. So far I have this: public IObservable<Boolean> GettingUDPMessages(IPEndPoint localEP) { var udp = BaseComms.UDPBaseStringListener(localEP) .Where(msg => msg.Data.Contains("running")) .Select(s => true); return Observable .Timeout(udp, TimeSpan.FromSeconds(5)) .Catch(Observable.Return(false)); } The issues with this are:- Once a false

Difference between catch and onErrorResumeNext

本小妞迷上赌 提交于 2019-12-23 08:33:14
问题 In RxJS, there seems to be very little difference between an Observable instance's catch method and onErrorResumeNext method, besides the fact that onErrorResumeNext concatenates the original Observable with the Observable parameters whether an error happens or not. If that's the case, isn't the naming a bit confusing? Because in case there is an error , onErrorResumeNext works exactly the same way than catch does: var testObservable = Rx.Observable.return(1).concat(Rx.Observable.throw("Error

Rx Framework: execute an action on timeout without interrupting the original observable sequence

拟墨画扇 提交于 2019-12-23 08:06:10
问题 Given an observable source, generated by polling the (changes of a) state of a low-level device... // observable source metacode: IObservable<DeviceState> source = Observable.Interval(TimeSpan.FromSeconds(0.5)) .Select(tick => new DeviceState(_device.ReadValue())) .DistinctUntilChanged(); ... and a consumer that updates the UI... // UI metacode: service.GetObservableDeviceStates() .Subscribe(state => viewModel.CurrentState = state.ToString()); ... I need to execute a custom action after x

Why does this Observable.Generate overload cause a memory leak? [Using Timespan < 15ms]

限于喜欢 提交于 2019-12-23 07:04:18
问题 The following Rx.NET code will use up about 500 MB of memory after about 10 seconds on my machine. var stream = Observable.Range(0, 10000) .SelectMany(i => Observable.Generate( 0, j => true, j => j + 1, j => new { N = j }, j => TimeSpan.FromMilliseconds(1))); stream.Subscribe(); If I use the Observable.Generate overload without a Func<int, TimeSpan> parameter my memory usage plateaus at 35 MB. var stream = Observable.Range(0, 10000) .SelectMany(i => Observable.Generate( 0, j => true, j => j +

Why does this Observable.Generate overload cause a memory leak? [Using Timespan < 15ms]

流过昼夜 提交于 2019-12-23 07:04:08
问题 The following Rx.NET code will use up about 500 MB of memory after about 10 seconds on my machine. var stream = Observable.Range(0, 10000) .SelectMany(i => Observable.Generate( 0, j => true, j => j + 1, j => new { N = j }, j => TimeSpan.FromMilliseconds(1))); stream.Subscribe(); If I use the Observable.Generate overload without a Func<int, TimeSpan> parameter my memory usage plateaus at 35 MB. var stream = Observable.Range(0, 10000) .SelectMany(i => Observable.Generate( 0, j => true, j => j +

How to wrap SqlDataReader with IObservable properly?

柔情痞子 提交于 2019-12-23 06:09:26
问题 I would like to explore the possibility to use IObservable<T> as a wrapper around a SqlDataReader . Until now we were using the reader to avoid materializing the entire result in the memory and we did so using blocking synchronous API. Now we want to try and use asynchronous API in conjunction with the .NET Reactive Extensions. However, this code will have to coexist with a synchronous code as adopting the asynchronous ways is a gradual process. We already know that this mix of synchronous

How to wrap SqlDataReader with IObservable properly?

筅森魡賤 提交于 2019-12-23 06:09:18
问题 I would like to explore the possibility to use IObservable<T> as a wrapper around a SqlDataReader . Until now we were using the reader to avoid materializing the entire result in the memory and we did so using blocking synchronous API. Now we want to try and use asynchronous API in conjunction with the .NET Reactive Extensions. However, this code will have to coexist with a synchronous code as adopting the asynchronous ways is a gradual process. We already know that this mix of synchronous

How to cancel a composed RxJS observable

浪子不回头ぞ 提交于 2019-12-23 05:45:35
问题 Folks, I have an app using RxJS to handle mouse events. I am composing these events into more complex observable 'gestures'. One such gesture is "shake". The series of events I am trying to compose are: mousedown mousemove left mousemove right mousemove left mousemove right mouseup What I am finding is that mousedown mouseup mousemove left mousemove right mousemove left mousemove right is also triggering the same result. I have made a fiddle demonstrating the issue on codepen. My question in

Reactive Extensions and Retry

无人久伴 提交于 2019-12-23 05:45:13
问题 So a series of articles popped on my radar this morning. It started with this question, which lead to the original example and source code on GitHub. I rewrote it slightly, so I can start using it in Console and Service applications: public static class Extensions { static readonly TaskPoolScheduler Scheduler = new TaskPoolScheduler(new TaskFactory()); // Licensed under the MIT license with <3 by GitHub /// <summary> /// An exponential back off strategy which starts with 1 second and then 4,

How to Subscribe to IObservable Sequence, force completion, and retrieve all data without race conditions

孤街醉人 提交于 2019-12-23 03:45:31
问题 There is a pattern I'm having trouble with when working with observables. I am working with a bluetooth device. I send a message to that device telling it to do something and notify me of the result or results. The device starts sending notifications (could go for 10ms or 20s) I wait for the device to finish sending notifications. sometimes this will be a specific message from the device and sometimes I just won't receive any more messages for a timeout period. I convert the messages to a