Пример #1
0
        private void Login(object o)
        {
            IsLoading = true;
            LoginRequestModel.Email    = LoginRequestModel.Email.Trim();
            LoginRequestModel.Password = (o as PasswordBox).Password;

            if (!ValidateInput(LoginRequestModel.Password))
            {
                IsLoading = false;
                return;
            }


            Thread thread = new System.Threading.Thread(
                new System.Threading.ThreadStart(
                    delegate() {
                var requestResult = Authentification.SignIn(LoginRequestModel);

                Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal,
                                                           new Action(() => {
                    // here we are back in the UI thread

                    if (requestResult.Success)
                    {
                        IsLoading = false;
                        GoToHome();
                    }
                    else
                    {
                        IsLoading = false;
                        MessageBox.Show(requestResult.Response);
                    }
                }));
            }
                    )
                );

            thread.Start();
        }