private void DoLogin(string userName, string password) { if (string.IsNullOrWhiteSpace(userName) || string.IsNullOrWhiteSpace(password)) { MessageBox.Show("Felhasználó név és/vagy jelszó nem lehet üres."); return; } OnOffControls.TurnOff(); Services.AuthenticationClient.Login(userName, password, false, response => { if (response.wasSuccessful) { Dispatcher.BeginInvoke( () => { // These are bound in other pages too, they can be called only by Dispatcher StaticData.UserData.IsAuthenticated = true; StaticData.UserData.UserName = userName; StaticData.UserData.UserId = response.userId; AppBarMenu.SetAppBarToLoggedIn(); // Refresh the AppBar items if (NavigationService.CanGoBack) { NavigationService.GoBack(); } }); new TaskFactory().StartNew( async() => { // Subscribe to push notifications try { await PushNotification.AcquirePushChannel(); } catch (Exception e) { //Dispatcher.BeginInvoke(() => // MessageBox.Show("Nem sikerült aktiválni az értesítő szolgáltatást. Próbálj meg kijelentkezni, majd újra bejelentkezni.")); } try { PushNotification.ResetTile(); } catch (Exception e) { } }); // Wait a bit before starting the prompt, otherwise it will not take any effect Thread.Sleep(500); // Show feedback from successful login Dispatcher.BeginInvoke( () => new ToastPrompt() { Message = "Sikeres bejelentkezés", }.Show()); } else // un-successful login { Dispatcher.BeginInvoke( () => { MessageBox.Show("Hibás felhasználó név és/vagy jelszó"); OnOffControls.TurnOn(); }); } }); }