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);
                            }));
                        }
                    }
                });

System.Windows.Application.Current.Dispatcher.BeginInvoke的更多相关文章

  1. WPF 的 Application.Current.Dispatcher 中,为什么 Current 可能为 null

    原文:WPF 的 Application.Current.Dispatcher 中,为什么 Current 可能为 null 在 WPF 程序中,可能会存在 Application.Current.D ...

  2. WPF 的 Application.Current.Dispatcher 中,Dispatcher 属性一定不会为 null

    原文:WPF 的 Application.Current.Dispatcher 中,Dispatcher 属性一定不会为 null 在 WPF 程序中,可能会存在 Application.Curren ...

  3. System.InvalidOperationException: 'Cannot create more than one System.Windows.Application instance in the same AppDomain.'

    System.Windows.Application is a singleton: its constructor must only be invoked once (including App. ...

  4. Wpf Dispatcher.BeginInvoke((Action)delegate{}));

    <Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/w ...

  5. 开发客户端软件时,出现System.Windows.Markup.XamlParseException错误

    开发客户端软件时,出现System.Windows.Markup.XamlParseException错误,通过查看错误消息,发现TCPIP的一个COM组件在安装软件过程中被删除了,重新注册了一下TC ...

  6. Windows Phone编程中Dispatcher.BeginInvoke的使用

    在学习Windows Phone 程序开发时经常会使用到Dispatcher.BeginInvoke()的编程方法,可能许多初学者并不熟悉Dispatcher.BeginInvoke的使用方法以及为什 ...

  7. 【C#遗补】获取应用程序路径之System.IO.Directory.GetCurrentDirectory和System.Windows.Forms.Application.StartupPath的区别

    原文:[C#遗补]获取应用程序路径之System.IO.Directory.GetCurrentDirectory和System.Windows.Forms.Application.StartupPa ...

  8. 自动化测试 using System.Windows.Automation;

    frameworke3.0 及以上 using System.Windows.Automation; UIAutomationClient.dll UIAutomationClientsideProv ...

  9. Dispatcher.BeginInvoke()方法使用不当导致UI界面卡死的原因分析

    原文:Dispatcher.BeginInvoke()方法使用不当导致UI界面卡死的原因分析 前段时间,公司同事开发了一个小工具,在工具执行过程中,UI界面一直处于卡死状态. 通过阅读代码发现,主要是 ...

随机推荐

  1. 多视图学习(multiview learning)

    多视图学习(multi-view learning) 前期吹牛:今天这一章我们就是来吹牛的,刚开始老板在和我说什么叫多视图学习的时候,我的脑海中是这么理解的:我们在欣赏妹子福利照片的时候,不能只看45 ...

  2. BZOJ3489: A simple rmq problem

    设$i$的前驱为$p_i$,后继为$q_i$,把询问看成点$(L,R)$,有贡献的$i$满足$L\in(p_i,i]$且$R\in[i,q_i)$,询问的就是覆盖这个点的矩形的最大值.那么可以用可持久 ...

  3. git push如何至两个git仓库

    分别有仓库 A(github),B(JAE 的 git),本机为C. 假设以 a 仓库作为最终的使用仓库, b为发布仓库.分支都为 dev 第一步,增加远程仓库 git remote add orig ...

  4. Google Map API V3开发(5)

    Google Map API V3开发(1) Google Map API V3开发(2) Google Map API V3开发(3) Google Map API V3开发(4) Google M ...

  5. 深入理解javascript原型和闭包(15)——闭包

    前面提到的上下文环境和作用域的知识,除了了解这些知识之外,还是理解闭包的基础. 至于“闭包”这个词的概念的文字描述,确实不好解释,我看过很多遍,但是现在还是记不住. 但是你只需要知道应用的两种情况即可 ...

  6. [NHibernate]HQL查询

    目录 写在前面 文档与系列文章 查询的几种方式 HQL查询 一个例子 总结 写在前面 上篇文章介绍了nhibernate在项目中的基本配置,包括数据库连接字符串的设置,映射文件的配置及需注意的地方,这 ...

  7. 关于Hibernate5.x的那点事

    1.如果采用程序建表: 4.x版本: Configuration cfg = new Configuration().configure(); SchemaExport se = new Schema ...

  8. [Python] 利用Django进行Web开发系列(一)

    1 写在前面 在没有接触互联网这个行业的时候,我就一直很好奇网站是怎么构建的.现在虽然从事互联网相关的工作,但是也一直没有接触过Web开发之类的东西,但是兴趣终归还是要有的,而且是需要自己动手去实践的 ...

  9. MySQL 关联表批量修改(数据同步)

    update table1 t1 ,table2 t2 set t1.field1 = t2.field2 where t1.id = t2.id

  10. .htaccess 基础教程(四)Apache RewriteCond 规则参数

    Apache模块 mod_rewrite 提供了一个基于正则表达式分析器的重写引擎来实时重写URL请求.它支持每个完整规则可以拥有不限数量的子规则以及附加条件规则的灵活而且强大的URL操作机制.此UR ...