예제 #1
0
 public override void Close()
 {
     IntPtr ptr;
     Bid.ScopeEnter(out ptr, "<sc.SqlConnection.Close|API> %d#", this.ObjectID);
     try
     {
         SqlStatistics statistics = null;
         SNIHandle target = null;
         RuntimeHelpers.PrepareConstrainedRegions();
         try
         {
             target = SqlInternalConnection.GetBestEffortCleanupTarget(this);
             statistics = SqlStatistics.StartTimer(this.Statistics);
             lock (this.InnerConnection)
             {
                 this.InnerConnection.CloseConnection(this, this.ConnectionFactory);
             }
             if (this.Statistics != null)
             {
                 ADP.TimerCurrent(out this._statistics._closeTimestamp);
             }
         }
         catch (OutOfMemoryException exception3)
         {
             this.Abort(exception3);
             throw;
         }
         catch (StackOverflowException exception2)
         {
             this.Abort(exception2);
             throw;
         }
         catch (ThreadAbortException exception)
         {
             this.Abort(exception);
             SqlInternalConnection.BestEffortCleanup(target);
             throw;
         }
         finally
         {
             SqlStatistics.StopTimer(statistics);
         }
     }
     finally
     {
         SqlDebugContext context = this._sdc;
         this._sdc = null;
         Bid.ScopeLeave(ref ptr);
         if (context != null)
         {
             context.Dispose();
         }
     }
 }
예제 #2
0
 private void CheckSQLDebug(SqlDebugContext sdc)
 {
     uint currentThreadId = (uint) AppDomain.GetCurrentThreadId();
     RefreshMemoryMappedData(sdc);
     if (!sdc.active && sdc.fOption)
     {
         sdc.active = true;
         sdc.tid = currentThreadId;
         try
         {
             this.IssueSQLDebug(1, sdc.machineName, sdc.pid, sdc.dbgpid, sdc.sdiDllName, sdc.data);
             sdc.tid = 0;
         }
         catch
         {
             sdc.active = false;
             throw;
         }
     }
     if (sdc.active)
     {
         if (!sdc.fOption)
         {
             sdc.Dispose();
             this.IssueSQLDebug(0, null, 0, 0, null, null);
         }
         else if (sdc.tid != currentThreadId)
         {
             sdc.tid = currentThreadId;
             try
             {
                 this.IssueSQLDebug(2, null, sdc.pid, sdc.tid, null, null);
             }
             catch
             {
                 sdc.tid = 0;
                 throw;
             }
         }
     }
 }