线程在 WebService 和 ASPX 页面中被中止
当我运行长查询时,在 IIS 6 上运行的这个简单代码中出现线程被中止异常。
线程正在中止。
StackTrace:
at Oracle.DataAccess.Client.OpsSql.ExecuteReader(IntPtr opsConCtx, IntPtr& opsErrCtx, IntPtr& opsSqlCtx, IntPtr& opsDacCtx, IntPtr& opsReaderErrCtx, IntPtr opsSubscrCtx, Int32& isSubscrRegistered, Int32 bchgNTFNExcludeRowidInfo, Int32 bQueryBasedNTFNRegistration, Int64& query_id, OpoSqlValCtx*& pOpoSqlValCtx, String pCommandText, OpoDacValCtx*& pOpoDacValCtx, IntPtr[] pOpoPrmValCtx, String[] ppOpoPrmRefCtx, OpoMetValCtx*& pOpoMetValCtx, Int32 NoOfParams) at Oracle.DataAccess.Client.OracleCommand.ExecuteReader(Boolean requery, Boolean fillRequest, CommandBehavior behavior) at Oracle.DataAccess.Client.OracleCommand.ExecuteReader() at TestWeb._Default.runQuery() in C:\Users\xfx1874\Documents\Visual Studio 2008\Projects\TestWeb\TestWeb\Default.aspx.cs:line 65
源代码:
protected void launchButton_Click(object sender, EventArgs e)
{
Thread t = new Thread(new ThreadStart(runQuery));
exTime.Text = "launching...";
t.Start();
}
private void runQuery()
{
bool hasRows;
log("Start - " + DateTime.Now);
try
{
using (OracleConnection oracleConnection = new OracleConnection(OracleConnectionString))
{
oracleConnection.Open();
using (OracleCommand oracleCommand = new OracleCommand())
{
oracleCommand.Connection = oracleConnection;
oracleCommand.CommandTimeout = ORACLE_TIMEOUT;
oracleCommand.CommandText = query;
using (OracleDataReader oracleReader = oracleCommand.ExecuteReader())
{
hasRows = oracleReader.HasRows;
}
}
}
log("End - " + DateTime.Now);
}
catch (Exception ex)
{
log(DateTime.Now + " - Exception message: " + ex.Message + " \n StackTrace: " + ex.StackTrace);
throw;
}
}
I'm having the Thread was being aborted exception in this simple code, running on IIS 6 when I run a long query.
Thread was being aborted.
StackTrace:
at Oracle.DataAccess.Client.OpsSql.ExecuteReader(IntPtr opsConCtx, IntPtr& opsErrCtx, IntPtr& opsSqlCtx, IntPtr& opsDacCtx, IntPtr& opsReaderErrCtx, IntPtr opsSubscrCtx, Int32& isSubscrRegistered, Int32 bchgNTFNExcludeRowidInfo, Int32 bQueryBasedNTFNRegistration, Int64& query_id, OpoSqlValCtx*& pOpoSqlValCtx, String pCommandText, OpoDacValCtx*& pOpoDacValCtx, IntPtr[] pOpoPrmValCtx, String[] ppOpoPrmRefCtx, OpoMetValCtx*& pOpoMetValCtx, Int32 NoOfParams) at Oracle.DataAccess.Client.OracleCommand.ExecuteReader(Boolean requery, Boolean fillRequest, CommandBehavior behavior) at Oracle.DataAccess.Client.OracleCommand.ExecuteReader() at TestWeb._Default.runQuery() in C:\Users\xfx1874\Documents\Visual Studio 2008\Projects\TestWeb\TestWeb\Default.aspx.cs:line 65
Source code:
protected void launchButton_Click(object sender, EventArgs e)
{
Thread t = new Thread(new ThreadStart(runQuery));
exTime.Text = "launching...";
t.Start();
}
private void runQuery()
{
bool hasRows;
log("Start - " + DateTime.Now);
try
{
using (OracleConnection oracleConnection = new OracleConnection(OracleConnectionString))
{
oracleConnection.Open();
using (OracleCommand oracleCommand = new OracleCommand())
{
oracleCommand.Connection = oracleConnection;
oracleCommand.CommandTimeout = ORACLE_TIMEOUT;
oracleCommand.CommandText = query;
using (OracleDataReader oracleReader = oracleCommand.ExecuteReader())
{
hasRows = oracleReader.HasRows;
}
}
}
log("End - " + DateTime.Now);
}
catch (Exception ex)
{
log(DateTime.Now + " - Exception message: " + ex.Message + " \n StackTrace: " + ex.StackTrace);
throw;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过设置executionTimeout
http://msdn.microsoft.com/en-us/library/e1f13641.aspx
Have you tried setting your executionTimeout
http://msdn.microsoft.com/en-us/library/e1f13641.aspx