如何使用asp.net sql server 2005在后台运行存储过程?不使用线程.... [英] how to run stored procedure in background using asp.net sql server 2005? without using thread....

查看:82
本文介绍了如何使用asp.net sql server 2005在后台运行存储过程?不使用线程....的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用asp.net sql server 2005在后台运行存储过程?不使用线程?

How to run stored procedure in background using asp.net sql server 2005? Without using thread?

推荐答案

Hello Santosh,



请看下面的两篇文章。< br $> b $ b
Hello Santosh,

Please have a look at following two articles.

  • ADO.NET Asynchronous SQL Calls[^]
  • Asynchronous Execution of T-SQL command, MSSQL[^]


在实践中你不能。如果您不使用线程(无论是Thread类还是BackgroundWorker类),那么您的代码将在现有(即主要或UI)线程上运行。由于所有的ExecuteXXX方法都是阻塞的,所以它们都会等到SQL查询完成后再将控制权返回给你应用程序中的下一条指令。



理论上,你可以使用BeginExectuteNonQuery和EndExecuteNonQuery来实现它,这将允许异步操作,但由于这些中没有涉及进度报告,并且EndExecuteNonQuery是一个阻塞操作,除非您可以在所有可能的情况下准确预测SQL查询的执行时间,它是使用这些而不是线程是不实际的 - 与线程一起使用它们是如何使用的。
You can't, in practice. If you don't use a thread (be it a Thread class or a BackgroundWorker class) then your code will run on your existing (i.e. main, or UI) thread. Since all the ExecuteXXX methods are blocking, they will all wait until the SQL query is complete before they return control to the next instruction in your app.

In theory, you could do it with BeginExectuteNonQuery and EndExecuteNonQuery which will allows asynchronous operation, but since there is no progress reporting involved in these, and EndExecuteNonQuery is a blocking operation, unless you can predict the execution time of the SQL query exactly under all possible circumstances, it is not practical to use these instead of a thread - in conjunction with a thread is how they are expected to be used.


这篇关于如何使用asp.net sql server 2005在后台运行存储过程?不使用线程....的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆