Пример #1
0
        bool UnsafeNativeMethods.IMsoComponentManager.FRevokeComponent(IntPtr dwComponentID)
        {
            int key = (int)((long)dwComponentID);

            if (this._original == null)
            {
                return(false);
            }
            if (((this._components == null) || (key <= 0)) || !this._components.ContainsKey(key))
            {
                return(false);
            }
            if (((this._refCount == 1) && (SafeNativeMethods.GetCurrentThreadId() == this._creationThread)) && !this.RevokeComponent())
            {
                return(false);
            }
            this._refCount--;
            this._components.Remove(key);
            if (this._refCount <= 0)
            {
                this.Dispose();
            }
            if (key == this._activeComponentId)
            {
                this._activeComponent   = null;
                this._activeComponentId = 0;
            }
            if (key == this._trackingComponentId)
            {
                this._trackingComponent   = null;
                this._trackingComponentId = 0;
            }
            return(true);
        }
Пример #2
0
 internal ComponentManagerProxy(ComponentManagerBroker broker, UnsafeNativeMethods.IMsoComponentManager original)
 {
     this._broker         = broker;
     this._original       = original;
     this._creationThread = SafeNativeMethods.GetCurrentThreadId();
     this._refCount       = 0;
 }
Пример #3
0
 // Returns true if we need to marshal across threads to access this timer's HWND.
 //
 private bool GetInvokeRequired(IntPtr hWnd)
 {
     if (hWnd != IntPtr.Zero)
     {
         int pid;
         int hwndThread    = SafeNativeMethods.GetWindowThreadProcessId(new HandleRef(this, hWnd), out pid);
         int currentThread = SafeNativeMethods.GetCurrentThreadId();
         return(hwndThread != currentThread);
     }
     return(false);
 }
Пример #4
0
        bool UnsafeNativeMethods.IMsoComponentManager.FRevokeComponent(IntPtr dwComponentID)
        {
            int dwLocalComponentID = unchecked ((int)(long)dwComponentID);

            if (_original == null)
            {
                return(false);
            }

            if (_components == null || dwLocalComponentID <= 0 || !_components.ContainsKey(dwLocalComponentID))
            {
                return(false);
            }

            if (_refCount == 1 && SafeNativeMethods.GetCurrentThreadId() == _creationThread)
            {
                if (!RevokeComponent())
                {
                    return(false);
                }
            }

            _refCount--;
            _components.Remove(dwLocalComponentID);

            Debug.Assert(_refCount >= 0, "underflow on ref count");
            if (_refCount <= 0)
            {
                Dispose();
            }

            if (dwLocalComponentID == _activeComponentId)
            {
                _activeComponent   = null;
                _activeComponentId = 0;
            }
            if (dwLocalComponentID == _trackingComponentId)
            {
                _trackingComponent   = null;
                _trackingComponentId = 0;
            }

            return(true);
        }