private void EnsureHostIsOpen() { if (currentHost == null || !currentHost.IsOpen) { currentHost = getHost(); Action openAction = () => currentHost.Open(this); Dispatcher.Invoke(openAction); } }