Exemplo n.º 1
0
        private bool _disposed = false;         // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            if (disposing)
            {
                // dispose managed state (managed objects implemeting IDisposable).
                _log.Debug("Disposing instance: {0} (Completed: {1})", GetHashCode(), _completed);

                if (!_completed)
                {
                    _unitOfWork.Abort();
                }

                OnDispose();

                _log.Debug("Disposed instance: {0}...", GetHashCode());
            }

            // XXX: Never throw exceptions from this point forward, log them instead.
            //		Throwing exceptions from a finalizer can crash the app.

            // free unmanaged resources (unmanaged objects), if any, and set large fields to null.
            // Then enable finalizer override found below.

            _disposed = true;
        }