Пример #1
0
        protected SafeComWrapper(T target, bool rewrapping = false)
        {
            Target      = target;
            _rewrapping = rewrapping;

            if (!rewrapping && target != null)
            {
                _comSafe = ComSafeManager.GetCurrentComSafe();
                _comSafe.Add(this);
            }
        }
Пример #2
0
        protected virtual void Dispose(bool disposing)
        {
            lock (_disposalLockObject)
            {
                if (_isDisposed)
                {
                    return;
                }
                _isDisposed = true;
            }

            if (disposing)
            {
                _comSafe?.TryRemove(this);

                if (!_rewrapping && !IsWrappingNullReference && !HasBeenReleased)
                {
                    Release();
                }

                _comSafe = null;
            }
        }