我的InvokedRequired会发生什么? [英] What happen with my InvokedRequired?
问题描述
我的代码有什么问题?
为什么不做正确的陈述?
您的if语句具有三个条件-您在调试器中仅显示两个 个条件.
我怀疑这解释了为什么您看到奇怪的东西-但我认为您的代码不适合开头.一方面,您要测试两次相同的条件,这毫无意义(您是说其中一个是lockScreen
而不是loginScreen
?)-但更重要的是,如果 one 为这些InvokeRequired
属性返回false,即使InvokeRequired
对该表单返回true,您也不会在任何表单中使用BeginInvoke
.
我建议您将其分为三个独立的块,每个块都以一种形式进行检查和操作.
What wrong with my code ??
Why it not go to true statement ?
Your if statement has three conditions - you're only showing two of them in the debugger.
I suspect that explains why you're seeing something odd - but I don't think your code is appropriate to start with. For one thing, you're testing the same condition twice, which is pointless (did you mean one of them to be lockScreen
rather than loginScreen
?) - but more importantly, if one of those InvokeRequired
properties returns false, you won't be using BeginInvoke
for any of the forms... even if InvokeRequired
returned true for that form.
I suggest you split this up into three separate blocks, each of which checks and acts on a single form.
这篇关于我的InvokedRequired会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!