| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- using System;
- using System.Threading.Tasks;
- using System.Windows.Threading;
- using GalaSoft.MvvmLight;
- using GalaSoft.MvvmLight.Command;
- using GalaSoft.MvvmLight.Threading;
- namespace Egametang
- {
- public class MainViewModel : ViewModelBase
- {
- private Main main = new Main();
- private RelayCommand loginCmd = null;
- public MainViewModel()
- {
- loginCmd = new RelayCommand(AsyncLogin);
- }
- public string LoginResult
- {
- get
- {
- return main.LoginResult;
- }
- set
- {
- if (main.LoginResult == value)
- {
- return;
- }
- main.LoginResult = value;
- RaisePropertyChanged("LoginResult");
- }
- }
- public RelayCommand LoginCmd
- {
- get
- {
- return loginCmd;
- }
- }
- private void AsyncLogin()
- {
- var task = new Task(() =>
- {
- });
- task.ContinueWith(_ =>
- {
- DispatcherHelper.UIDispatcher.BeginInvoke(DispatcherPriority.Normal,
- new Action(() =>
- {
- LoginResult = "Login OK!";
- }));
- });
- task.Start(App.OrderedTaskScheduler);
- }
- public override void Cleanup()
- {
- base.Cleanup();
- }
- }
- }
|