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. jquery ripples水波纹效果( 涟漪效果)

    这个效果是我从bootstrap-material-design上面分离下来的,bootstrap-material-design的一些组件样式我不太不喜欢,但是非常喜欢这个水波纹效果,所以就有了这篇 ...

  2. centos 软件包安装与管理

    http://rpmfind.net/linux/RPM/index.html http://pkgs.org/ https://sourceforge.net/

  3. 调整Virtual Box硬盘大小

    我在Mac下使用Virtual Box安装Win7的虚拟机.因为之前装过Win7的32位版.现在因为机器内存升到8G,就可以划出4G来支持Win7虚拟机.所以就重新安装了Win7的64位版.在创建虚拟 ...

  4. Canvas实例

    <!doctype html> <html> <head> <meta charset="utf-8" /> <title&g ...

  5. CSS隐藏多余文字的几个方法

    通常偏移掉字体的方式是 (1)使用text-indent:-9999px; 可是他有一个局限性 他只适用于块级元素block而我们往往有时候想偏移掉的a上的字体所以问题就来了text-indent:- ...

  6. 子类可以有跟父类中同名的方法,但是会重写父类中的方法,甚至是root class中的方法

    /* 子类可以重写父类中的方法,甚至是root class中的方法,比如NSObeject 的new方法,但是后提示警告如下 Method is expected to return an insta ...

  7. 升级到 PHP-7 遇到的坑 及 经验分享

    注意:上面这张图是QQ群网友分享的,图中提到的“被移除的函数”,call_user_func 和 call_user_func_array 在 PHP-7.0 的正式版中是可用的,也许是当时的 测试版 ...

  8. C和指针 第五章 位数组

    5.4的习题:编写一组函数,实现维数组,函数原型如下: //指定位设置为1void set_bit(char bit_array[], unsigned bit_number); //指定位清零 vo ...

  9. windows系统和ubuntu虚拟机之间文件共享——samba

    参考:http://www.cnblogs.com/phinecos/archive/2009/06/06/1497717.html 一. samba的安装: sudo apt-get insall  ...

  10. linux Mint截图软件 Shutter

    安装shutter: sudo add-apt-repository ppa:shutter/ppa sudo apt-get update sudo apt-get install shutter ...