异步处理问题。.
c#中对数据库操作,
据说有异步处理。
如果可以请具体说一下。。谢谢~~!!!

解决方案 »

  1.   

    AJAX,异步处理数据,用javascript脚本在客户端调用服务器端数据
      

  2.   

    我仅从理论去讲下,具体其实有很资料,MSDN输入"异步调用"就可以学习到很多了1: 异步跟数据库没有关系2: 异步是你自己控制的3: 举个例说明下比较明白
       比如有个长时间的查询,从用户体验来说,你不能让客户死等,
       因此我们一般会 
          a 显示个进度条
          b 让用户可以先去做其他操作,而程序在执行查询完毕后弹出即时提示信息表明查询完毕,用户再去查看结果。
       为了达到此这样效果,我们就会用异步处理机制,一般是新开个新线程专门用于查询,流程大概如下:
       A 用户点击了画面上的查询按钮
       B 程序启动了一个线程去执行具体查询
       C 程序显示查询进度(线程不段输出进度信息)或用户去做其他操作
       D 线程执行完毕,此时进度条100%或弹出即时提示信息
    、 E 用户查看查询结果4: 实现异步基本说用单独线程或委托去实现。
       //委托方式(其实这是线程池方式,你用委托.net会在线程中你调配执行),比如
       public delegate void AsyncCaller(MethodInfo method, object target);
       AsyncCaller caller = new AsyncCaller(this.AsyncInvoke);
       IAsyncResult result = caller.BeginInvoke(method, target, null, null);
       while (!result.IsCompleted){
           Thread.Sleep(100);
       }
       caller.EndInvoke(result);  //自己写线程的方式,随便考段代码比如
      ParameterizedThreadStart threadStart = new ParameterizedThreadStart(this.ThreadStart);
      ExecuteSeed executeSeed = new ExecuteSeed();
      executeSeed.ManagementObj = target;
      executeSeed.MethodInfo = businessMethodDict[action].MethodInfo;
      Thread thread = new Thread(threadStart);
      thread.Start(executeSeed);
      while (executeSeed.Result == ResultKind.WAIT){
          if (executeSeed.Result == ResultKind.NG) throw executeSeed.Exception;
          Thread.Sleep(200);
      }
     if (executeSeed.Result == ResultKind.NG) throw executeSeed.Exception;
      

  3.   

    1 xmlhttrequest或Ajax 只是异步调用一个例子
    2 xmlhttrequest或Ajax 另一个重点是解决画面刷新问题