private void mgr_ConnectionCheckComplete(object sender, ServerConnectStatusEventArgs e) { // The Status event will contain information about the current login process, if Connected is false, then there is not yet a connection. // Unwire events that we are not using anymore, this prevents issues if the user uses the control after a failed login. ((CrmConnectionManager)sender).ConnectionCheckComplete -= mgr_ConnectionCheckComplete; ((CrmConnectionManager)sender).ServerConnectionStatusUpdate -= mgr_ServerConnectionStatusUpdate; if (!e.Connected) { // if its not connected pop the login screen here. if (e.MultiOrgsFound) { MessageBox.Show("Unable to Login to CRM using cached credentials. Org Not found", "Login Failure"); } else { MessageBox.Show("Unable to Login to CRM using cached credentials", "Login Failure"); } _resetUiFlag = true; CrmLoginCtrl.GoBackToLogin(); // Bad Login Get back on the UI. Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => { Title = "Failed to Login with cached credentials."; MessageBox.Show(Title, "Notification from ConnectionManager", MessageBoxButton.OK, MessageBoxImage.Error); CrmLoginCtrl.IsEnabled = true; })); _resetUiFlag = false; } else { // Good Login Get back on the UI if (e.Connected && !_bIsConnectedComplete) { ProcessSuccess(); } OutputLogger.WriteToOutputWindow(HostWindow.GetCaption(string.Empty, _mgr.CrmSvc).Substring(3), MessageType.Info); } }