zoukankan      html  css  js  c++  java
  • System.Windows.Application.Current.Dispatcher.BeginInvoke

    System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                               {
                                   if (True)
                                   {
                                      
                                   }
                               }));

    异步方法

                Task.Factory.StartNew(() =>
                {
                    ViewModel.ToDownload();
                });

    Task.Factory.StartNew<Update.UpdateConfig>(() =>
                    {
                        Thread.Sleep(3000);
                        bool isnew = Update.UpdateService.CheckNewVersion();
                        if (isnew)
                        {
                            UpdateConfig config=Update.UpdateService.GetNewVersion();
                            HasChecked = true;
                            return config;
                        }
                        return null;
                    }, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default)
                    .ContinueWith((e) =>
                    {
                        if (e.Exception == null)
                        {
                            if (e.Result != null)
                            {
                                Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                                {
                                    //弹出更新窗口
                                    Update.UpdateService.ShowUpdateWindowLoadComplete(e.Result, () =>
                                    {
                                        return true;
                                    }, Application.Current.MainWindow);
                                }));
                            }
                        }
                    });

  • 相关阅读:
    【C++基础汇总】参数传递
    常用VC快捷键
    美股交易规则
    xpath 总结1
    【字符集】字符集和编码知识【转】
    【字符集】ASCII 表
    【win32编程学习】常用技巧总结
    【win32编程学习】 调用dll
    【win32编程学习】 创建自己的dll
    充实的生活
  • 原文地址:https://www.cnblogs.com/m7777/p/4877224.html
Copyright © 2011-2022 走看看