system.reactive

Can Reactive Extensions (Rx) be used across process or machine boundaries?

那年仲夏 提交于 2019-12-21 04:00:40
问题 Vaguely remember seeing some discussions on this quite a while back but haven't heard anything since. So basically are you able to subscribe to an IObservable on a remote machine? 回答1: You can use IObservable.Remotable to use observables directly from other machines via .NET Remoting. 回答2: Another possible solution could be to use named pipes. There is an excellent NuGet package NamedPipeWrapper, see the source on GitHub. It would be easy to write a thin RX wrapper over this, i.e. subscribe

How do I await a response from an RX Subject without introducing a race condition?

☆樱花仙子☆ 提交于 2019-12-21 03:42:56
问题 I have a service that allows a caller to send commands and receive responses asynchronously. In a real application, these actions are fairly disconnected (some action will send a command, and the responses will be process independently). However, in my tests, I need to be able to send a command and then wait for the (first) response before continuing the test. The responses are published using RX, and my first attempt at the code was something like this: service.SendCommand("BLAH"); await

IAsyncRepository or IObservableRepository for silverlight 4 + WCF Data Services

末鹿安然 提交于 2019-12-20 14:44:38
问题 Update 2 : @Enigmativity has a brilliant answer. I've implemented this into a IObservableRepository<T> . Details in my answer below. Question: So I've changed most of the question (See edit history) I would just like it if someone commented/validated/puked on my design. =) So typically my Repos look like this: public interface IRepository<T> where T : class { T GetById(int id); IQueryable<T> GetAll(); void InsertOnSubmit(T entity); void DeleteOnSubmit(T entity); int SubmitChanges(); } But

Wrap a file watcher in reactive extensions

孤街醉人 提交于 2019-12-20 14:11:19
问题 I've been looking at wrapping a file watcher in an observable to aide in processing events but I'm having some trouble figuring out how to get the behaviour I want out of it. The file watcher watches a directory into which files are placed. When a file is first placed into that directory the Created event is fired on the file watcher. However if the file is large or the network connection slow then a series of Changed events are fired as the file updates. I don't want to process the file

Advantages of .NET Rx over classic events?

夙愿已清 提交于 2019-12-20 09:45:20
问题 .NET 4.0 beta 2 has introduced the IObservable and IObserver interfaces. What are the advantages compared to classic .NET events? Doesn't this solve the same problem? 回答1: You can use IObservable as an event, replacing code that exposes events with properties of type IObservable, but that's not really the point. There are two important things to understand about IObservable: It unifies two concepts that we didn't know how to unify before : asynchronous operations (which typically return a

A code example illustrating the difference between the paradigms of async/await and Reactive (Rx) extension?

痞子三分冷 提交于 2019-12-20 08:39:02
问题 Both the System.Reactive extension for .NET and new C# 5.0 (.NET 4.5) async/await pursue (or based on) future and promises constructs paradigm (approach). Can you give the (*) simplest C# code example illustrating the difference between them? (*) Is it possible without I/O, internet or database connections? Update: Well, let me reformulate if this question seemed to be answered before. Why would one add and start using Reactive (Rx) extensions for .NET while using native .NET Iobservable

What is the conceptual difference between SynchronizationContext and TaskScheduler

馋奶兔 提交于 2019-12-20 08:35:29
问题 Stephen Toub blogged that Both SynchronizationContext and TaskScheduler are abstractions that represent a “scheduler”, something that you give some work to, and it determines when and where to run that work. There are many different forms of schedulers. For example, the ThreadPool is a scheduler: you call ThreadPool.QueueUserWorkItem to supply a delegate to run, that delegate gets queued, and one of the ThreadPool’s threads eventually picks up and runs that delegate. Your user interface also

Buffer data from database cursor while keeping UI responsive

核能气质少年 提交于 2019-12-20 03:53:20
问题 I have a database catalog that is populated, and a cursor that can be used to retrieve objects. This catalog can obviously be very large, and what I'd like to do is use ReactiveUI to buffer the data in, while keeping the UI data-bound and responsive. I followed the steps here to translate my IEnumerable into an IObservable , as shown here: public class CatalogService { ... public IObservable<DbObject> DataSource { get { return Observable.Create<DbObject>(obs => { var cursor = Database

Get next event in sequence every second with reactive-extensions

血红的双手。 提交于 2019-12-20 02:15:24
问题 I have the below types ... public class NewsFeed { public event EventHandler<NewsItemEventArgs> NewItem; ..... } public class NewsItemEventArgs : EventArgs { public NewsItem Item; public NewsItemEventArgs(NewsItem newsItem) { Item = newsItem; } } public class NewsItem { public int Id { get; set; } public string Title { get; set; } public string Body { get; set; } } The NewsFeed's NewItem event fires events with eventArgs of type NewsItemEventArgs. In my system the events are published in

RuntimeBinderException while using Newtonsoft Json with dynamic after installing Reactive Extensions

ぐ巨炮叔叔 提交于 2019-12-20 02:04:21
问题 I was using the following code: public async Task<string> LoginAsync(string username, string password) { //removed irrelevant code from snippet var response = await JSonConvert.DeSerializeObjectAsync<dynamic>(responseText); return (response.success == SUCCESS ? response.data.sid : String.Empty); } This worked find until I installed Reactive Extensions through NuGet. From that point on the last line of the method simply throw a RuntimeBinderException : {"'Newtonsoft.Json.Linq.JObject' does not