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服务异步调用,待续。。

  • 相关阅读:
    机器学习实战第五章Logistic回归
    pyhton pandas库的学习
    pyhton numpy库的学习
    ISLR第8章The Basics of Decision Trees
    ISLR第10章 Unsupervised Learning
    吴恩达机器学习第5周Neural Networks(Cost Function and Backpropagation)
    ISLR第9章SVM
    ISLR第六章Linear Model Selection and Regularization
    ISLR第五章Resampling Methods(重抽样方法)
    ISLR第二章
  • 原文地址:https://www.cnblogs.com/log-long/p/3275552.html
Copyright © 2011-2022 走看看