protected virtual void Dispose(bool disposing)
        {
            // If it's working, give it a few seconds to see if can finish
            for (int i = 1; IsWorking() && i <= 300; ++i)
            {
                Thread.Sleep(10);
            }

            if (!IsWorking())
            {
                if (CurrentTransaction != null)
                {
                    CurrentTransaction.Dispose();
                    CurrentTransaction = null;
                }

                if (CurrentConnection != null)
                {
                    CurrentConnection.Dispose();
                    CurrentConnection = null;
                }
            }
            else
            {
//#if DEBUG
//                if (System.Diagnostics.Debugger.IsAttached)
//                {
//                    System.Diagnostics.Debugger.Break();
//                }
//#endif
                CurrentTransaction = null;
                CurrentConnection  = null;
            }
        }
Exemple #2
0
        public void Dispose()
        {
            if (Interlocked.Exchange(ref disposeSignaled, 1) != 0)
            {
                return;
            }

            try
            {
                if (CurrentTransaction != null)
                {
                    CurrentTransaction.Commit();
                }
            }
            finally
            {
                if (CurrentTransaction != null)
                {
                    CurrentTransaction.Dispose();
                    scopedTransaction = null;
                }
                if (CurrentConnection != null)
                {
                    CurrentConnection.Dispose();
                    scopedConnection = null;
                }
                if (Disposed != null)
                {
                    Disposed(this, EventArgs.Empty);
                }
            }

            isDisposed = true;
        }
Exemple #3
0
 public void Rollback()
 {
     CurrentTransaction?.Rollback();
     CurrentTransaction?.Dispose();
     if (CurrentConnection?.State == ConnectionState.Open)
     {
         CurrentConnection.Close();
     }
     CurrentConnection?.Dispose();
 }
Exemple #4
0
 public void Commit()
 {
     CurrentTransaction?.Commit();
     CurrentTransaction?.Dispose();
     if (CurrentConnection?.State == ConnectionState.Open)
     {
         CurrentConnection.Close();
     }
     CurrentConnection?.Dispose();
 }
Exemple #5
0
        /// <summary>
        /// 执行与释放或重置非托管资源关联的应用程序定义的任务。
        /// </summary>
        public void Dispose()
        {
            if (CurrentTransaction != null)
            {
                CurrentTransaction.Dispose();
                CurrentTransaction = null;
            }

            if (CurrentConnection != null)
            {
                CurrentConnection.Dispose();
            }
        }
Exemple #6
0
        protected virtual void Dispose(bool disposing)
        {
            if (!IsWorking())
            {
                if (CurrentTransaction != null)
                {
                    CurrentTransaction.Dispose();
                    CurrentTransaction = null;
                }

                if (CurrentConnection != null)
                {
                    CurrentConnection.Dispose();
                    CurrentConnection = null;
                }
            }
        }
        protected virtual void Dispose(bool disposing)
        {
            if (!_disposedValue)
            {
                if (CurrentTransaction != null)
                {
                    CurrentTransaction.Dispose();
                    CurrentTransaction = null;
                }

                if (CurrentConnection != null)
                {
                    CurrentConnection.Dispose();
                    CurrentConnection = null;
                }

                _disposedValue = true;
            }
        }
        protected virtual void Dispose(bool disposing)
        {
            if (!IsWorking())
            {
                if (CurrentTransaction != null)
                {
                    CurrentTransaction.Dispose();
                    CurrentTransaction = null;
                }

                if (CurrentConnection != null)
                {
                    CurrentConnection.Dispose();
                    CurrentConnection = null;
                }
            }

            //CEFDebug.WriteInfo($"Dispose connection: " + _id);
        }