system.reactive

Is the Reactive Framework (RX) available for use in Mono yet?

北慕城南 提交于 2020-01-03 09:04:14
问题 Been searching but the only thing I found was http://evain.net/blog/articles/2009/07/30/rebasing-system-reactive-to-the-net-clr which I got to work, but it feels like there should be a simpler way, specially since rx was first release back in mid 09. 回答1: You can now download it for .NET 3.5SP1 and .NET 4, so I wouldn't be at al surprised if it just worked against recent releases of Mono - no Silverlight doohickies required at all. Having said that, I haven't tried it at all against Mono :)

Why does the Task.WhenAny not throw an expected TimeoutException?

孤街浪徒 提交于 2020-01-03 07:30:54
问题 Please, observe the following trivial code: class Program { static void Main() { var sw = new Stopwatch(); sw.Start(); try { Task.WhenAny(RunAsync()).GetAwaiter().GetResult(); } catch (TimeoutException) { Console.WriteLine("Timed out"); } Console.WriteLine("Elapsed: " + sw.Elapsed); Console.WriteLine("Press Enter to exit"); Console.ReadLine(); } private static async Task RunAsync() { await Observable.StartAsync(async ct => { for (int i = 0; i < 10; ++i) { await Task.Delay(500, ct); Console

How to cancel Rx Based Web Request in Windows Phone 7

痞子三分冷 提交于 2020-01-03 05:23:15
问题 In my application i am using a Rx based web request for fetching the data from the server. Suppose if i want to cancel the request, what i need to do? 回答1: Try using the extension method TakeUntil(someEvent), before Subscribe, where SomeEvent could be an Observable.FromEventPattern fired from button click event, for example. Let us know, regards, 回答2: If you're asking how to cancel the subscription to an observable that is performing the web request then all you need to do is call .Dispose()

How we can use RX framework in WCF for long running process and frequent UI updation?

前提是你 提交于 2020-01-03 05:22:12
问题 Recently i came to know about Rx framework and seems very promising. I have a doubt in it. Suppose from my UI [may it be winforms or web pages], i make a call to webservice and sending a List. So my calls is like --> myWCFServiceMethod(List empLists). Inside this service methods, for each employee object, i need to make again another service calls and get the result of it and do some kind of DB operations [saving and updation] and finally sends back the status of each employee to the client

RX: How to process n buffered items from a sequence then wait t seconds before processing the next n items?

主宰稳场 提交于 2020-01-02 19:27:23
问题 I'm trying to figure out how to process n buffered items from a sequence then wait t seconds before processing the next n items? Here's a crude form of what I'm trying to do, using Thread.Sleep(). I want to avoid Thread.Sleep() and do it properly. static void Main(string[] args) { var t = Observable.Range(0, 100000); var query = t.Buffer(20); query.ObserveOn(NewThreadScheduler.Default) .Subscribe(x => DoStuff(x)); Console.WriteLine("Press ENTER to exit"); Console.ReadLine(); } static void

Observe PropertyChanged on items in an ObservableCollection using System.Reactive

ぐ巨炮叔叔 提交于 2020-01-02 18:04:45
问题 I have: public class Vm { private ObservableCollection<Thing> _things; public ObservableCollection<Thing> Things { get { return _things ?? (_things = new ObservableCollection<Thing>()); } } } And public class Thing :INotifyPropertyChanged { private string _value; public string Value { get { return _value; } set { if (value == _value) return; _value = value; OnPropertyChanged(); } } public event PropertyChangedEventHandler PropertyChanged; [NotifyPropertyChangedInvocator] protected virtual

Observe PropertyChanged on items in an ObservableCollection using System.Reactive

随声附和 提交于 2020-01-02 18:04:41
问题 I have: public class Vm { private ObservableCollection<Thing> _things; public ObservableCollection<Thing> Things { get { return _things ?? (_things = new ObservableCollection<Thing>()); } } } And public class Thing :INotifyPropertyChanged { private string _value; public string Value { get { return _value; } set { if (value == _value) return; _value = value; OnPropertyChanged(); } } public event PropertyChangedEventHandler PropertyChanged; [NotifyPropertyChangedInvocator] protected virtual

Should I use List<IObserver> or simply Action<T> to keep track of an IObservable's subscribers?

故事扮演 提交于 2020-01-02 08:30:14
问题 I'm implementing the IObservable<T> interface on some classes. I used Reflector to figure out how this is typically done in Rx. Concerning how an observable keeps track of its subscribers and notifies them via their OnNext method, I stumbled upon code similar to this: private List<Observer<T>> observers; // subscribe a new observer: public IDisposable Subscribe(IObserver<T> observer) { observers.Add(observer); ... } // trigger all observers' OnNext method: ... foreach (IObserver<T> observer

Catching events prior to subscription with FromEventPattern

大兔子大兔子 提交于 2020-01-02 05:33:29
问题 I'm writing a listener for messages using the Rx framework. The problem I'm facing is that the library I'm using uses a consumer that publishes events whenever a message has arrived. I've managed to consume the incoming messages via Observable.FromEventPattern but I have a problem with the messages that are already in the server. At the moment I have the following chain of commands Create a consumer Create an observable sequence with FromEventPattern and apply needed transformations Tell the

Calling network services in parallel using RxJava. Is this the right way?

我怕爱的太早我们不能终老 提交于 2020-01-02 04:37:05
问题 Idea is to make 3 network calls in parallel. (I am using Google as the servies for demo purpose. The following works but not sure if this is the right way or it can be simplified. What should I do if I have to combine the responses of all the three searches? Please advise. public class GoogleSearchRx { public static void main(String args[]) { CountDownLatch latch = new CountDownLatch(3); search("RxJava").subscribeOn(Schedulers.io()).subscribe( links -> { links.forEach(link -> out.println