线程在 WebService 和 ASPX 页面中被中止

发布于 2024-10-13 03:51:09 字数 2093 浏览 9 评论 0原文

当我运行长查询时,在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

牵你手 2024-10-20 03:51:09

您是否尝试过设置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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文