Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Silverlight WCF Proxy async only?

Why do the Silerlight-generated WCF proxy class(es) offer only async calls?

There are cases where I don't really need the async pattern (for example in a BackgroundWorker)

EDIT : Sometimes I need to process the results of two WCF calls. It would have been much simpler if I could have waited (the business of the app allows that) for both calls to end and then process.. but noooo.... async! :P

like image 368
Andrei Rînea Avatar asked Aug 17 '09 08:08

Andrei Rînea


2 Answers

As I understand it, the aim here is to make it hard for people to do the wrong thing (sync. IO from the UI). If you are using the WCF classes, you'll probably have to live with it.

like image 177
Marc Gravell Avatar answered Oct 23 '22 00:10

Marc Gravell


There's actually a technical reason you can't do sync calls, at least from the 'main' browser thread, which is that the browser invokes all the plug-in API calls on the same thread, so if SL were to block that thread while waiting for the network callback, the network callback wouldn't get through and the app would deadlock. That said, the sync API would work fine if initiated from a different thread -- ie, if the application first does a QueueUserWorkItem to get off the browser thread -- but we felt it would be confusing to offer the sync option and have it only work some of the time.

like image 21
alexdej Avatar answered Oct 23 '22 01:10

alexdej