Example #1
0
        public void Dispose()
        {
            if (IsDisposed)
            {
                throw new ObjectDisposedException("Imageflow JobContext");
            }

            // Do not allocate or throw exceptions unless (disposing)
            Exception e = null;

            try
            {
                e = _handle.DisposeAllowingException();
            }
            finally
            {
                UnpinAll();

                //Dispose all managed data held for context lifetime
                if (_toDispose != null)
                {
                    foreach (var active in _toDispose)
                    {
                        active.Dispose();
                    }
                    _toDispose = null;
                }
                GC.SuppressFinalize(this);
                if (e != null)
                {
                    throw e;
                }
            }
        }