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

  • 相关阅读:
    二、java基础-运算符_控制语句_break_continue_return
    一、Servlet之14道面试题
    Java程序员需要掌握的技能
    java内存溢出实战
    java虚拟机JVM基础
    常见数据结构与算法整理总结(下)
    常见数据结构与算法整理总结(上)
    Java实现八大排序算法
    23种设计模式图集
    引用iscroll的一个封装方法
  • 原文地址:https://www.cnblogs.com/buzi521/p/WPF.html
Copyright © 2020-2023  润新知