禁用Windows窗体上的所有活动 [英] Disable All Events on a Windows Form

查看:115
本文介绍了禁用Windows窗体上的所有活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有什么办法可以暂时禁用的Windows窗体的所有事件?

Is there any way to temporarily disable ALL events on an windows form?

我在这里处理的辅助线程被破坏的主线程上的事件的情况。 (主线程事件正在修改的控件的数据绑定到所使用的辅助线程变量的内容。)寻找一种方法来锁定的形式,直到在辅助线程结束的处理。 (显然,移动处理主线程会做到这一点 - 但它也将冻结的用户界面,这不是我想要的任一)

I have situation where processing on a secondary thread is being corrupted by events on the main thread. (The main thread events are modifying the contents of controls that are data-bound to variables used by the secondary thread.) Looking for a way to "lock" the form until the processing on the secondary thread finishes. (Obviously, moving processing to the main thread would do this--but it would also "freeze" the UI, which isn't what I want either.)

推荐答案

感谢所有为你出色的帮助。真的帮了决策过程。 Upvotes给大家。使用锁结束了。 (即是,如果在每个事件处理程序的开始语句检查锁定状态,然后继续。)繁琐,不是所有的冷在技术上,而是简单,它的工作。

Thanks all for your excellent assistance. Really helped the decision making process. Upvotes to everyone. Ended up using a lock. (I.e. an if statement at the start of each event handler checks the lock status before continuing.) Tedious and not all that "cool" technically, but simple and it worked.

这篇关于禁用Windows窗体上的所有活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆