示例#1
0
        protected override void OnFinalRevoke()
        {
            if (null != hwndSource)
            {
                CommandManager.RemoveCanExecuteHandler((UIElement)hwndSource.RootVisual, CanExecuteRoutedEventHandler);
                CommandManager.RemoveExecutedHandler((UIElement)hwndSource.RootVisual, ExecuteRoutedEventHandler);

                if (!hwndSource.CheckAccess())
                {
                    hwndSource.Dispatcher.Invoke(hwndSource.Dispose);
                }
                else
                {
                    hwndSource.Dispose();
                }
                hwndSource = null;
            }

            if (null != observer)
            {
                observer.Dispose();
                observer = null;
            }
            base.OnFinalRevoke();
        }