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

  • 相关阅读:
    六、Doris数据流与控制流
    五、Doris数据分布
    非洛达芯片检测聚合教程NOT AIROHA CHIP
    慧联A8最新检测使用教程V2.0.3
    SpringBoot集成thymeleaf增删改查示例
    记一次Linux磁盘满盘/dev/vda1目录清理记录
    悦虎固件升级到底有啥用?二代为例
    PerfDog性能狗简介
    macOS常用命令
    像素格式与纹理压缩
  • 原文地址:https://www.cnblogs.com/buzi521/p/WPF.html
Copyright © 2011-2022 走看看