WPF MVVM - Correct way to consume a web service asynchronously
I have implemented MVVM in my WPF application. I was wondering what is the correct way to consume a Web Service from WPF MVVM app.
So far, I have created a DataAccess interface and a class that implements this interface. This would serve as a facade / proxy to the web service. The ViewModel gets a reference to this class as the constructor parameter so it can make any calls to get/set d开发者_Python百科ata, in this case it will be a Web service call. I would appreciate if you can guide me with some hints and / or direct me to some online resource.
I know about 3 different ways of writting asynchronous code for MVVM:
the classical using callbacks
using coroutines:
- project Caliburn
- Using C# 2.0 iterators to simplify writing asynchronous code
- many more..
using Rx "Reactive Extensions" (this the newest):
- The Joy of Rx: Building an Asynchronous API with Rx and IQueryable
- Using Reactive Extensions in Silverlight
We aware that except the "classical" solution all the others use advanced techniques.
精彩评论