My login window is highly unresponsive. I'm not really sure why is this. I'm using MVVM light as my MVVM framework. I handle the login button click through a RelayCommand, the command handler (I know it's bad practice to pass the whole PasswordBox as a parameter, it's breaking the MVVM pattern, but please focus on the question). The command handler is the following:
LoginButtonClicked = new GalaSoft.MvvmLight.Command.RelayCommand<System.Windows.Controls.PasswordBox>((pwdBox) => { if (string.IsNullOrWhiteSpace(this.Username) || string.IsNullOrWhiteSpace(pwdBox.Password)) { MessageBoxRequested("Neuspešno logovanje", "Molimo unesite i korsničko ime i lozinku"); return; } ProgressDialogRequested(); bool validated = false; try { validated = TotalSport.Framework.UserManagement.EmployeeStore.ValidateEmployee(this.Username, pwdBox.Password); } catch (System.Data.Entity.Core.ObjectNotFoundException) { MessageBoxRequested("Logovanje neuspešno", "Zaposleni sa tim imenom ne postoji!"); pwdBox.Password = string.Empty; return; } pwdBox.Password = string.Empty; System.Diagnostics.Debug.WriteLine(validated); if (validated) { Client.Views.MainWindow mw = new Client.Views.MainWindow(this.Username); mw.Show(); CloseRequested(); } else MessageBoxRequested("Logovanje neuspešno", "Pogrešna lozinka!"); }); ValidateEmployee hashed the supplied string and compares it to a value stored in the DB. I think it's the cause of my problems (it most likely is, since it's a slow hash - PBDKF2 - and a DB query in a single method), but I'm not sure why. It has nothing to do with the UI thread and the LoginWindow itself.
The relevant event handlers on the actual window:
((ViewModels.LoginViewModel)this.DataContext).MessageBoxRequested += (title, message) => { this.ShowMessageAsync(title, message); }; ((ViewModels.LoginViewModel)this.DataContext).ProgressDialogRequested += () => { this.ShowProgressAsync("Test", "test"); }; ((ViewModels.LoginViewModel)this.DataContext).CloseRequested += () => { this.Close(); }; Any input on this?