// IComObject methods public void Open() { if (_wpfApartment != null) { throw new InvalidOperationException(); } // start a new thread with WPF Dispatcher _wpfApartment = new WpfApartment(); // attach the input queue of the current thread to that of c var thisThreadId = NativeMethods.GetCurrentThreadId(); _wpfApartment.Invoke(() => NativeMethods.AttachThreadInput(thisThreadId, NativeMethods.GetCurrentThreadId(), true)); // create an instance of BrowserWindow on the WpfApartment's thread _browserWindow = _wpfApartment.Invoke(() => new BrowserWindow(_eventHelper) { Left = 200, Top = 200, Width = 640, Height = 480 }); _wpfApartment.Invoke(() => _browserWindow.Initialize()); }
public void Close() { if (_wpfApartment == null) { return; } if (_browserWindow != null) { _wpfApartment.Invoke(() => _browserWindow.Close()); } CloseWpfApartment(); }