zoukankan      html  css  js  c++  java
  • WPF-模拟Application.DoEvents的类

     /// <summary>
        /// 
        /// </summary>
        public static class DispatcherHelper
        {
            /// <summary>
            /// Simulate Application.DoEvents function of <see cref=" System.Windows.Forms.Application"/> class.
            /// </summary>
            [SecurityPermissionAttribute ( SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode )]
            public static void DoEvents ( )
            {
                DispatcherFrame frame = new DispatcherFrame ( );
                Dispatcher.CurrentDispatcher.BeginInvoke ( DispatcherPriority.Background,
                    new DispatcherOperationCallback ( ExitFrames ), frame );

                try
                {
                    Dispatcher.PushFrame ( frame );
                }
                catch ( InvalidOperationException )
                {
                }
            }
            /// <summary>
            /// 
            /// </summary>
            /// <param name="f"></param>
            /// <returns></returns>
            private static object ExitFrames ( object frame )
            {
                ( ( DispatcherFrame ) frame ).Continue = false;

                return null;
            }
        }

  • 相关阅读:
    算法导论笔记:21用于不相交集合的数据结构
    算法导论笔记:19斐波那契堆
    xfs管理2T以上大分区
    tcpdump确认服务器连接的交换机信息
    pcp分布式监控工具
    ssh相关命令
    一次ddos攻击
    ssh-agent && ssh-agent forward && SSH ProxyCommand
    变更hostname
    yum第三方源
  • 原文地址:https://www.cnblogs.com/buzi521/p/WPF.html
Copyright © 2011-2022 走看看