Example #1
0
        // Dispose(bool disposing) executes in two distinct scenarios.
        // If disposing equals true, the method has been called directly
        // or indirectly by a user's code. Managed and unmanaged resources
        // can be disposed.
        // If disposing equals false, the method has been called by the
        // runtime from inside the finalizer and you should not reference
        // other objects. Only unmanaged resources can be disposed.
        private void Dispose(bool disposing)
        {
            try
            {
                // Check to see if Dispose has already been called.
                if (!disposed)
                {
                    if (disposing)
                    {
                        // If there is a not complete transaction, abort it.
                        if (!complete)
                        {
                            Rollback();
                        }

                        //we don't dispose the transaction participants.
                        //only clean
                        Inner.Clean();
                        Outer.Clean();

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

                        scopeTimer = null;
                    }
                    // Note disposing has been done.
                    disposed = true;
                }
            }
            catch (Exception ex)
            {
                Log.Warn(ex, "Dispose failed.");
                //IGNORE - we are just cleaning.
            }
            finally
            {
                //we completed the work now.
                complete = true;
            }
        }