Silverlight WCF Proxy async only?

2019-01-15 18:35发布

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

3条回答
冷血范
2楼-- · 2019-01-15 19:30

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.

查看更多
Lonely孤独者°
3楼-- · 2019-01-15 19:37

Andrei, there ar emethods that even using the async pattern, allows you write expressive code, esasy to read and maintian, without becoming crazy wating 4 async requests, by just simplifying the way you write your code. give a look to this library http://syncwcf.codeplex.com/

查看更多
乱世女痞
4楼-- · 2019-01-15 19:38

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.

查看更多
登录 后发表回答