コード例 #1
0
        internal void HandleTimeoutOrThreadAbort(Exception ex)
        {
            bool isFatal = false;

            if (isKillQueryConnection)
            {
                // Special connection started to cancel a query.
                // Abort will prevent recursive connection spawning
                Abort();
                if (ex is TimeoutException)
                {
                    Throw(new MyCatException(Resources.Timeout, true, ex));
                }
                else
                {
                    return;
                }
            }

            try
            {
                // Do a fast cancel.The reason behind small values for connection
                // and command timeout is that we do not want user to wait longer
                // after command has already expired.
                // Microsoft's SqlClient seems to be using 5 seconds timeouts
                // here as well.
                // Read the  error packet with "interrupted" message.
                CancelQuery(5);
                driver.ResetTimeout(5000);
                if (Reader != null)
                {
#if NETSTANDARD1_3
                    foreach (var x in Reader)
                    {
                        x.Dispose();
                    }
#else
                    foreach (var x in Reader)
                    {
                        x.Close();
                    }
#endif
                    Reader = null;
                }
            }
            catch (Exception ex2)
            {
                MyCatTrace.LogWarning(ServerThread, "Could not kill query, " +
                                      " aborting connection. Exception was " + ex2.Message);
                Abort();
                isFatal = true;
            }
            if (ex is TimeoutException)
            {
                Throw(new MyCatException(Resources.Timeout, isFatal, ex));
            }
        }
コード例 #2
0
 internal void Abort()
 {
     try
     {
         driver.Close();
     }
     catch (Exception ex)
     {
         MyCatTrace.LogWarning(ServerThread, String.Concat("Error occurred aborting the connection. Exception was: ", ex.Message));
     }
     finally
     {
         this.isInUse = false;
     }
     SetState(ConnectionState.Closed, true);
 }