public void Release(bool activateWindowIfNeeded) { if (Container == null) { return; } Container.Initialized -= OnOwnerInitialized; var container = Container; Container = null; if (container.Window == null || lockMode == SplashScreenLock.None) { return; } SplashScreenHelper.InvokeAsync(container.Window, () => { if (activateWindowIfNeeded && !SplashScreenHelper.ApplicationHasActiveWindow()) { container.ActivateWindow(); } SplashScreenHelper.UnlockWindow(container); }, DispatcherPriority.Render); }