zoukankan      html  css  js  c++  java
  • 异步调用开发应用总结

    异步调用的一些开发应用总结:

    WEB应用需要异步调用,保证在一些比较耗时的功能执行过程同时不阻塞主线程执行,尤其是WCF服务调用,使用异步调用还是很有必要的。

    关于异步调用,分别总结下方法的异步调用与WCF服务的异步调用。

    方法异步调用与同步调用示例:

     public string TestMethod(string Code, object userState)
            {

    //同步
    GetName(Code);

    //异步
                try
                {
                    AsyncGetName asyncDelegateGetName = delegate(string Code_bp)
                    {
                        return this.Command.GetName(Code_bp);
                    };
                    IAsyncResult iaResult = asyncDelegateGetName.BeginInvoke(Code, delegate(IAsyncResult resultCallBack)
                    {
                        System.Runtime.Remoting.Messaging.AsyncResult result = (System.Runtime.Remoting.Messaging.AsyncResult)resultCallBack;
                        AsyncGetName asyncDelegate = (AsyncGetName)result.AsyncDelegate;
                        if (result.IsCompleted)
                        {
                            string asyncResult = asyncDelegate.EndInvoke(resultCallBack);
                            this.GetNameCompleted(this, new INewTestManage_GetNameCompletedEventArgs(new object[] { asyncResult }, null, false, result.AsyncState));
                        }

                    }, userState);
                }
                catch
                {
                    throw;
                }
            }

    WCF服务异步调用,待续。。

  • 相关阅读:
    51nod1432 独木舟
    51nod1126 求递推序列的第N项
    Alice, Bob, Oranges and Apples CodeForces
    区间dp
    平面几何基础
    图的割点、桥与双连通分支
    hihocoder 1305 区间求差
    hdu 2444 The Accomodation of Students 【二分图匹配】
    状压dp
    hdu 1525 Euclid's Game【 博弈论】
  • 原文地址:https://www.cnblogs.com/log-long/p/3275552.html
Copyright © 2011-2022 走看看