填坑,上文说的 C# Event.ClickCount 解决垃圾鼠标带来的烦恼 中及时刷新UI方法

如下:

 [SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
        public static void RefreshButtonClickProperty()
        {
            DispatcherFrame frame = new DispatcherFrame();
            Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new DispatcherOperationCallback(ExitFrames), frame);
            try { Dispatcher.PushFrame(frame); }
            catch (InvalidOperationException e)
            {
            }
        }

public static object ExitFrames(object f)
{
((DispatcherFrame)f).Continue = false;


return null;
}

 

在对控件的某些属性进行设置后可及时调用该方法进行刷新

posted on 2018-12-03 17:07  Khandasas  阅读(239)  评论(0)    收藏  举报