wpf BackgroundWorker 的简单用法

1. 登陆中。。 登陆成功

            BackgroundWorker worker = new BackgroundWorker();
                worker.DoWork += (o, ea) =>
                {
                  
                    Login(sName, sPassword);
                };
                worker.RunWorkerCompleted += (o, ea) =>
                {
                    if (ea.Error != null)
                    {
                        tbMsg.Text = ea.Error.Message;
                        Password.Clear();
                        Password.Focus(); 
                    }
                    else
                    {
                        loginStatus.Text = "登录成功!";
                        if ((bool)chkRemember.IsChecked)
                        {
                            setRememberMe(true, sName, sPassword);
                        }
                     
                    }
                }; 
                loginStatus.Text = "正在登录中...";
                worker.RunWorkerAsync();

 

wpf BackgroundWorker 的简单用法

上一篇:C#实现foreach


下一篇:wpf Dispatcher 与 DispatcherPriority