zoukankan      html  css  js  c++  java
  • 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.

  • 相关阅读:
    Jquery Plugin模版
    jquery之extend
    java反射技术实例
    java基础汇总
    Java学习路线
    java的一个爬虫
    Java深度理解——Java字节代码的操纵
    java编程思想-基础
    hdu 5201 The Monkey King【容斥原理+组合数学】
    容斥原理
  • 原文地址:https://www.cnblogs.com/RChen/p/1377782.html
Copyright © 2011-2022 走看看