private void Switch(Task <IHTMLBinding> binding, HTMLLogicWindow window, TaskCompletionSource <IHTMLBinding> tcs) { var oldvm = Binding?.Root; var fireFirstLoad = false; Binding = binding.Result; if (_CurrentWebControl != null) { _CurrentWebControl.HTMLWindow.ConsoleMessage -= ConsoleMessage; _CurrentWebControl.Dispose(); } else { fireFirstLoad = true; } _CurrentWebControl = _NextWebControl; _NextWebControl = null; _CurrentWebControl.HTMLWindow.Crashed += Crashed; _CurrentWebControl.Show(); _Window = window; var inav = _UseINavigable ? Binding.Root as INavigable : null; if (inav != null) { inav.Navigation = this; } _Window.State = WindowLogicalState.Opened; _Window.OpenAsync().ContinueWith(t => EndAnimation(Binding.Root)); _Navigating = false; FireNavigate(Binding.Root, oldvm); tcs?.SetResult(Binding); if (fireFirstLoad) { OnFirstLoad?.Invoke(this, EventArgs.Empty); } }
private void Switch(Task <IHTMLBinding> iBinding, HTMLLogicWindow iwindow, TaskCompletionSource <IHTMLBinding> tcs) { object oldvm = (Binding != null) ? Binding.Root : null; Binding = iBinding.Result; if (_CurrentWebControl != null) { _CurrentWebControl.HTMLWindow.ConsoleMessage -= ConsoleMessage; _CurrentWebControl.Dispose(); } else if (OnFirstLoad != null) { OnFirstLoad(this, EventArgs.Empty); } _CurrentWebControl = _NextWebControl; _NextWebControl = null; //_CurrentWebControl.Crashed += Crashed; _CurrentWebControl.Show(); _Window = iwindow; var inav = _UseINavigable ? Binding.Root as INavigable : null; if (inav != null) { inav.Navigation = this; } _Window.State = WindowLogicalState.Opened; _Window.OpenAsync().ContinueWith(t => EndAnimation(Binding.Root)); _Navigating = false; FireNavigate(Binding.Root, oldvm); if (tcs != null) { tcs.SetResult(Binding); } }