Best Practise for handling Post requests in windows phone (silverlight)

I want to ask how do you usually architectural responsible for processing Post requests in your mobile apps(all pretty much the same thing in normal silverlite applications). Since we are forced to make all calls "very" multithreaded, there are questions about building the infrastructure for data exchange.

A. UI application
B. Creating A HttpWebRequest
V. Method for BeginGetRequestStream
G. Method for the BeginGetResponse

Cases who want to discuss a few:

1. Transmission of additional parameters from B to C and d
2. Update And G
3. The removal work B, C, d in a separate dll and sharing data with And

As I have now:
1. using IAsyncResult.State for transmission structure, which pack all I need
2. use this.Dispatcher.BeginInvoke(delegate{...});
3. was planning to make a ViewModel for the page, and update from, the Question of how to tell the UI that it is time to reload and pick up all the data from the ViewModel.

I would be grateful for your recipes of cooking this cereal. And that is my version of I don't think dostatochno beautiful and comfortable)
October 8th 19 at 02:19
2 answers
October 8th 19 at 02:21
I prepared as follows:
There is a page (View) and model (ViewModel) to query the client about methods to be a signature:

void LoadSomeData<t>(object request, Action<response, t> onLoad Action<erroreventargs<t>> onError = null, T userState = null)
</erroreventargs<t></response></t>


The client for service rendered in a separate dll, then everything is as usual, react to user action (via ICommand) pull the appropriate method, at the same time including ProgressIndicator and blocking (if required) interface. Return onLoad or onError, unblocking of the UI and the ViewModel updated the desired fields, say UI it's time to upgrade by implementing the ViewModel from INotifyPropertyChanged.
October 8th 19 at 02:23
we are forced to make all calls "very" multithreaded

Well noticed. It would have been much easier if MS allowed to decide for themselves where to apply multithreading... But if they went down this path — and then you step, namely to use Reactive Extensions.

That is, if you want everything to be properly architectural plan MS, then examine the Rx. But be warned — their study will take at least a week + get ready for a paradigm shift of thinking.

Find more questions by tags Microsoft SilverlightWindows Phone