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; }
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); }