InvokeRequired [英] InvokeRequired

查看:67
本文介绍了InvokeRequired的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


我需要迭代所有TreeView工作线程上的节点。这样做的时候,

我会打电话给InvokeRequired并通过

" Invoke()"路由所有方法/属性调用按要求。然而,对于每个TreeNode,我在树上遇到的对象
,我必须通过

" Invoke()"来对这个对象路由方法/属性调用。同样。我不会这么认为,因为TreeNode和本身不是一个控件

所以它的方法/属性可能需要小心

调用Invoke()必要时自己(如果他们需要调用

TreeView方法)。它是否正确?非常感谢。

Hi there,

I need to iterate all "TreeView" nodes on a worker thread. When doing so,
I''ll call "InvokeRequired" and route all method/property calls through
"Invoke()" as required. However, for each "TreeNode" object I encounter in
the tree, must I also route method/property calls on this object through
"Invoke()" as well. I wouldn''t think so since a "TreeNode" is not a control
in its own right so its methods/properties would presumably take care
calling "Invoke()" themselves if necessary (if they need to call the
"TreeView" methods for something). Is this correct? Thanks very much.

推荐答案

Samuel White写道:
Samuel White wrote:

你好,


我需要迭代所有TreeView工作线程上的节点。这样做的时候,

我会打电话给InvokeRequired并通过

" Invoke()"路由所有方法/属性调用按要求。然而,对于每个TreeNode,我在树上遇到的对象
,我必须通过

" Invoke()"来对这个对象路由方法/属性调用。同样。我不会这么认为,因为TreeNode和本身不是一个控件

所以它的方法/属性可能需要小心

调用Invoke()必要时自己(如果他们需要调用

TreeView方法)。它是否正确?非常感谢。

Hi there,

I need to iterate all "TreeView" nodes on a worker thread. When doing so,
I''ll call "InvokeRequired" and route all method/property calls through
"Invoke()" as required. However, for each "TreeNode" object I encounter in
the tree, must I also route method/property calls on this object through
"Invoke()" as well. I wouldn''t think so since a "TreeNode" is not a control
in its own right so its methods/properties would presumably take care
calling "Invoke()" themselves if necessary (if they need to call the
"TreeView" methods for something). Is this correct? Thanks very much.



我认为你是对的。所有的控件都运行在同一个UI

线程中,所以如果你对TreeView控件进行了检查,那么就不需要再次在TreeNode上调用它了
..


HTH。

JW

I think you are correct. All the controls are running in the same UI
thread, so if you did the check on the TreeView control, there is no
need to call it again on the TreeNode again..

HTH.
J.W.


塞缪尔,


你需要像对待任何控件一样限制对TreeNode的访问。

该规则几乎适用于System.Windows.Form中的所有内容

命名空间。


Brian


Samuel White写道:
Samuel,

You''ll need to limit access to a TreeNode as you would any control.
That rule applies to almost everything in the System.Windows.Form
namespace.

Brian

Samuel White wrote:

你好,


我需要迭代所有TreeView工作线程上的节点。这样做的时候,

我会打电话给InvokeRequired并通过

" Invoke()"路由所有方法/属性调用按要求。然而,对于每个TreeNode,我在树上遇到的对象
,我必须通过

" Invoke()"来对这个对象路由方法/属性调用。同样。我不会这么认为,因为TreeNode和本身不是一个控件

所以它的方法/属性可能需要小心

调用Invoke()必要时自己(如果他们需要调用

TreeView方法)。它是否正确?非常感谢。
Hi there,

I need to iterate all "TreeView" nodes on a worker thread. When doing so,
I''ll call "InvokeRequired" and route all method/property calls through
"Invoke()" as required. However, for each "TreeNode" object I encounter in
the tree, must I also route method/property calls on this object through
"Invoke()" as well. I wouldn''t think so since a "TreeNode" is not a control
in its own right so its methods/properties would presumably take care
calling "Invoke()" themselves if necessary (if they need to call the
"TreeView" methods for something). Is this correct? Thanks very much.


Brian Gideon写道:
Brian Gideon wrote:

Samuel,


你需要像对待任何控件一样限制对TreeNode的访问。

该规则几乎适用于System.Windows.Form中的所有内容

名称空间。


Brian


Samuel White写道:
Samuel,

You''ll need to limit access to a TreeNode as you would any control.
That rule applies to almost everything in the System.Windows.Form
namespace.

Brian

Samuel White wrote:

>你好,

我需要迭代所有的TreeView。工作线程上的节点。这样做的时候,我会打电话给InvokeRequired。并通过
Invoke()路由所有方法/属性调用按要求。然而,对于每个TreeNode,我在树中遇到的对象,我还必须通过
Invoke()对这个对象进行方法/属性调用。同样。我不会这么认为,因为TreeNode和它本身不是一个控件,所以它的方法/属性可能需要小心
调用Invoke()。必要时自己(如果他们需要调用
TreeView方法)。它是否正确?非常感谢。
>Hi there,

I need to iterate all "TreeView" nodes on a worker thread. When doing so,
I''ll call "InvokeRequired" and route all method/property calls through
"Invoke()" as required. However, for each "TreeNode" object I encounter in
the tree, must I also route method/property calls on this object through
"Invoke()" as well. I wouldn''t think so since a "TreeNode" is not a control
in its own right so its methods/properties would presumably take care
calling "Invoke()" themselves if necessary (if they need to call the
"TreeView" methods for something). Is this correct? Thanks very much.



但是如果他已经检查了TreeView控件,他是否需要再次检查每个TreeNode的
。我假设他检查了TreeView控件后,

线程应该已经正确封送到UI线程。

But if he already checked the TreeView Control, does he need to check
each TreeNode again. I assume after he checked TreeView control, the
thread should already be marshaled properly to the UI thread.


这篇关于InvokeRequired的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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