示例#1
0
        public NativeHandleHostAdapter(INativeHandleContract nativeHandleContract, ObserverHostAdapter adapter)
        {
            Debug.Assert(null != nativeHandleContract);
            contract = new ContractHandle(nativeHandleContract);
            observer = adapter;

            PresentationSource.AddSourceChangedHandler(this, OnSourceChanged);
            Dispatcher.ShutdownFinished += OnDispatcherShutdown;

            //if (null == observer) return;
            //observer.Execute += ExecutedRoutedCommandHandler;
            //observer.CanExecute += CanExecuteRoutedCommandHandler;
        }
示例#2
0
        protected virtual void Dispose(bool disposing)
        {
            PresentationSource.RemoveSourceChangedHandler(this, OnSourceChanged);
            Dispatcher.ShutdownFinished -= OnDispatcherShutdown;

            if (null != observer)
            {
                //    observer.Execute -= ExecutedRoutedCommandHandler;
                //    observer.CanExecute -= CanExecuteRoutedCommandHandler;
                observer = null;
            }

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

            hWnd = new HandleRef(null, IntPtr.Zero);
        }