Example #1
0
        /// <include file='doc\WindowPane.uex' path='docs/doc[@for="WindowPane.Dispose1"]' />
        /// <devdoc>
        ///     Called when this window pane is being disposed.
        /// </devdoc>
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (_vsShell != null)
                {
                    try {
                        // Don't check for return code because here we can't do anything in case of failure.
                        _vsShell.UnadviseBroadcastMessages(_broadcastEventCookie);
                    } catch (COMException) { /* do nothing */ }
                    _vsShell = null;
                    _broadcastEventCookie = 0;
                }

                IWin32Window window = Window;
                if (window is IDisposable)
                {
                    try {
                        ((IDisposable)window).Dispose();
                    } catch (Exception) {
                        Debug.Fail("Failed to dispose window");
                    }
                }
                window = null;

                if (_commandService != null && _commandService is IDisposable)
                {
                    try {
                        ((IDisposable)_commandService).Dispose();
                    } catch (Exception) {
                        Debug.Fail("Failed to dispose command service");
                    }
                }
                _commandService = null;

                if (_parentProvider != null)
                {
                    _parentProvider = null;
                }

                if (_helpService != null)
                {
                    _helpService = null;
                }

                // Do not clear _provider.  SetSite will do it for us.

                _zombie = true;
            }
        }
        /// <include file='doc\VsWindowPane.uex' path='docs/doc[@for="VsWindowPane.ClosePane"]/*' />
        /// <devdoc>
        ///     Called by Visual Studio when it wants to close this pane.  The pane may be
        ///     later re-opened by another call to CreatePaneWindow.
        /// </devdoc>
        public virtual int ClosePane()
        {
            OnWindowPaneClose();

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

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

            if (vsBroadcastEventCookie != 0 && vsShell != null)
            {
                vsShell.UnadviseBroadcastMessages(vsBroadcastEventCookie);
                vsShell = null;
                vsBroadcastEventCookie = 0;
            }

            toolboxService = null;
            host           = null;
            hostChecked    = false;
            return(NativeMethods.S_OK);
        }
        /// <summary>
        /// Releases unmanaged and - optionally - managed resources
        /// </summary>
        /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
        protected override void Dispose(bool disposing)
        {
            if (IsDisposed)
            {
                return;
            }
            IsDisposed = true;

            if (!disposing || _shellService == null)
            {
                return;
            }
            if (_broadcastEventCookie != 0)
            {
                _shellService.UnadviseBroadcastMessages(_broadcastEventCookie);
                _broadcastEventCookie = 0;
            }

            if (_propertyEventCookie == 0)
            {
                return;
            }
            _shellService.UnadviseShellPropertyChanges(_propertyEventCookie);
            _propertyEventCookie = 0;
        }
Example #4
0
 private void UnadviseBroadcastMessages()
 {
     if (shellService != null && broadcastEventCookie != 0)
     {
         shellService.UnadviseBroadcastMessages(broadcastEventCookie);
         broadcastEventCookie = 0;
     }
 }
 public void Dispose()
 {
     if (shellService != null && broadcastCookie != 0)
     {
         shellService.UnadviseBroadcastMessages(broadcastCookie);
         broadcastCookie = 0;
     }
 }
Example #6
0
 // --------------------------------------------------------------------------------------------
 /// <summary>
 /// Closes a window pane.
 /// </summary>
 /// <returns>
 /// If the method succeeds, it returns S_OK. If it fails, it returns an error code.
 /// </returns>
 /// <remarks>
 /// Inheritors must override the OnClose method to add custom behavior to the window pane.
 /// The Dispose method is called independently of the result of OnClose.
 /// </remarks>
 // --------------------------------------------------------------------------------------------
 int IVsWindowPane.ClosePane()
 {
     if (_VsShell != null)
     {
         NativeMethods.ThrowOnFailure(_VsShell.UnadviseBroadcastMessages(_BroadcastEventCookie));
         _VsShell = null;
         _BroadcastEventCookie = 0;
     }
     try
     {
         OnClose();
     }
     finally
     {
         Dispose();
     }
     return(NativeMethods.S_OK);
 }
Example #7
0
 public void Dispose()
 {
     if (_vsShell != null)
     {
         if (_vsShellBroadcastEventsCookie != 0)
         {
             _vsShell.UnadviseBroadcastMessages(_vsShellBroadcastEventsCookie);
             _vsShellBroadcastEventsCookie = 0;
         }
     }
 }
Example #8
0
 public void Dispose()
 {
     if (_vsShell != null)
     {
         try
         {
             // Don't check for return code because here we can't do anything in case of failure.
             _vsShell.UnadviseBroadcastMessages(_broadcastEventCookie);
         }
         catch (Exception) { /* do nothing */ }
         _vsShell = null;
         _broadcastEventCookie = 0;
     }
 }
Example #9
0
 private void DisconnectFromShellEvents()
 {
     if (_vsShell != null)
     {
         if (_vsShellEventsCookie != 0)
         {
             _vsShell.UnadviseShellPropertyChanges(_vsShellEventsCookie);
             _vsShellEventsCookie = 0;
         }
         if (_vsShellBroadcastEventsCookie != 0)
         {
             _vsShell.UnadviseBroadcastMessages(_vsShellBroadcastEventsCookie);
             _vsShellBroadcastEventsCookie = 0;
         }
     }
 }
        /// <summary>
        ///     Implements IDisposable
        /// </summary>
        public void Dispose()
        {
            if (!disposed)
            {
                if (provider != null)
                {
                    provider.Dispose();
                }

                if (shell != null)
                {
                    shell.UnadviseBroadcastMessages(shellCookie);
                }

                disposed = true;
            }
        }
Example #11
0
 public void Dispose()
 {
     if (cookie != 0 &&
         shellService != null)
     {
         try
         {
             shellService.UnadviseBroadcastMessages(cookie);
         }
         catch (Exception)
         {
             // Possibly VS is shutting down so ignore the exception.
         }
         finally
         {
             cookie       = 0;
             shellService = null;
         }
     }
     GC.SuppressFinalize(this);
 }
 public void Dispose()
 {
     _shell.UnadviseBroadcastMessages(_broadcastEventCookie);
 }