Easier programming asynchronous calls

Asynchronous calls can improve scalability, however, it's always more difficult for us to do programming jobs under an asynchronous calling manner. The main reason is, asynchronous calls need callbacks everywhere, thus local variables and parameters in the current scope can not be easily passed through (ofcause you can use lambdas and anonymous methods, but they can't solve all the problems either). Moreover, when you need to perform many tasks which should be completed in an sequential order, for example, the latter asynchronous call may need to use the result of a previous one, it'll be even harder to implement, and if you've done it, the code may look terribly wired and not intuitive enough for understanding and maintaining.

For these reasons, programming asynchronous calls in synchronous manner is needed. I've looked through some articles on the internet and I think some resources listed here may worth you to have a look at:

1. Jeffrey Richter's Power Threading library.
http://www.wintellect.com/CS/blogs/jeffreyr/archive/2008/12/04/7380.aspx#7383

In the implementation for this library Jeff has used the C# 2.0 language's great 'iterator' feature (yield return) to achieve it. By following his examples you can easily program asynchronous calls in an synchronous manner and at the same time, you can still take the advantage of various C# features like foreach/lock/try..catch, and so on. Also, this awesome library has an version for Silverlight.

2. Synchronous Web Service Calls with Silverlight 2: Dispelling the async-only myth
http://www.codeproject.com/KB/silverlight/SynchronousSilverlight.aspx

This great article by Daniel Vaughan is for calling WCF Services in Silverlight, in an synchronous programming style, it's also easy to understand and the idea is explained in detail.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值