开发者

RX: Best approach to async download a list of something from a WCF-service?

开发者 https://www.devze.com 2023-02-20 16:40 出处:网络
The result Im after is a list (WPF) of items that is populated one at a time async from a web service (WCF). I figured RX could be a good option for this?

The result Im after is a list (WPF) of items that is populated one at a time async from a web service (WCF). I figured RX could be a good option for this?

My web service method is returning an array of strings (for now) and at the client-side Im using:

var list = Observable.FromAsyncPattern<string[]>(clien开发者_开发知识库t.BeginList, client.EndList);

But now what? Im not familiar with RX at all and I feel very lost. Anyhow I guess my web service has to stream the list instead of sending it in a chunk if I want them to pop in continously?


FromObservablePattern returns a Func<IObservable> (or possibly with arguments if the service takes any), so you call the delegate and then subscribe to the source:

var list = Observable.FromAsyncPattern<string[]>(client.BeginList, client.EndList);

list().Subscribe(items =>
{
    // items is the string[]
});
0

精彩评论

暂无评论...
验证码 换一张
取 消