我的InvokedRequired会发生什么? [英] What happen with my InvokedRequired?

查看:111
本文介绍了我的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屋!

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