propertygrid throw error&“在一个线程上创建的控件不能作为不同线程上的控件的父级。” [英] propertygrid throwing error "Controls created on one thread cannot be parented to a control on a diffrent thread."

查看:58
本文介绍了propertygrid throw error&“在一个线程上创建的控件不能作为不同线程上的控件的父级。”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我有两个线程。

每个都创建一个新的propertygrid。

在属性网格中,我有一个带有颜色编辑器的属性。 />

每当我点击组合框更改

中的''颜色'时,第一个帖子就可以了。


尝试修改属性网格中颜色的任何其他线程

抛出:

"在一个线程上创建的控件不能作为<上的控件的父级br />
不同的线程。


属性网格线程安全吗?是否有任何错误的静态变量

应该是threadstatic?任何解决方案?


谢谢,


jaire

In my application I have two threads.
Each of them creates a new propertygrid.
In the property grid I have a property with a color editor.

Whenever i am clicking on the combo box to change the ''Color'' in the
first thread is fine.

Any other thread that tries to modify the color in the property grid
throws:
"Controls created on one thread cannot be parented to a control on a
diffrent thread."

Is property grid thread safe? Is there any wrong static variable that
should be threadstatic? Any solution?

Thanks,

jaire

推荐答案

jaire< ja ***** @ eresmas.com>写道:
jaire <ja*****@eresmas.com> wrote:
在我的应用程序中,我有两个线程。
每个都创建一个新的propertygrid。
在属性网格中我有一个带有颜色编辑器的属性。

每当我点击组合框来更改
第一个帖子中的''颜色'都没问题。

任何其他尝试修改颜色的线程属性网格
抛出:
在一个线程上创建的控件不能成为
不同线程上的控件的父级。

属性网格线程是否安全?是否有任何错误的静态变量
应该是threadstatic?任何解决方案?
In my application I have two threads.
Each of them creates a new propertygrid.
In the property grid I have a property with a color editor.

Whenever i am clicking on the combo box to change the ''Color'' in the
first thread is fine.

Any other thread that tries to modify the color in the property grid
throws:
"Controls created on one thread cannot be parented to a control on a
diffrent thread."

Is property grid thread safe? Is there any wrong static variable that
should be threadstatic? Any solution?




任何一个表单应该只在一个线程上创建控件。你只需要从那个线程访问那些控件,除了

调用Control.Invoke,Control.BeginInvoke,Control.CreateGraphics和

Control.InvokeRequired。



http://www.pobox.com/~skeet/csharp/m...#windows.forms


- -

Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet

如果回复群组,请不要给我发邮件



Any one form should only have controls created on one thread. You
should only ever access those controls from that thread, apart from
calling Control.Invoke, Control.BeginInvoke, Control.CreateGraphics and
Control.InvokeRequired.

See
http://www.pobox.com/~skeet/csharp/m...#windows.forms

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


感谢您的快速回复,但我认为我不清楚:


我的应用程序创建了两个线程。

每个线程创建一个表单。

每个表单创建一个属性网格。

颜色编辑器只能从他各自的线程访问。


问题看起来有什么东西c虽然每个属性网格都是在不同的线程中创建的,但是由反射创建的

ColorEditor()

总是一样的。


谢谢。


***通过开发人员指南 http://www.developersdex.com ***

不要只是参加USENET ......获得奖励!
Thanks for your quick reply but I think I was not clear:

My application creates two threads.
Each thread creates a form.
Each form creates a property grid.
The color editor is only accessed from his respective thread.

The problem looks like there is something cached on the ColorUI.
Although each property grid is created in a different thread, the
ColorEditor created by reflection ([Editor(typeof(ColorEditor),
typeof(System.Drawing.Design.UITypeEditor))])
is always the same.

Thanks.

*** Sent via Developersdex http://www.developersdex.com ***
Don''t just participate in USENET...get rewarded for it!


Jesus Arevalo< ja ** ***@eresmas.com>写道:
Jesus Arevalo <ja*****@eresmas.com> wrote:
感谢您的快速回复,但我认为我不清楚:

我的应用程序创建了两个线程。
每个线程创建一个表单。
每个表单都会创建一个属性网格。
颜色编辑器只能从他各自的线程访问。

问题看起来像是在ColorUI上缓存了一些东西。
虽然每个属性grid是在不同的线程中创建的,由反射创建的ColorEditor([Editor(typeof(ColorEditor),
typeof(System.Drawing.Design.UITypeEditor))])
总是同样。
Thanks for your quick reply but I think I was not clear:

My application creates two threads.
Each thread creates a form.
Each form creates a property grid.
The color editor is only accessed from his respective thread.

The problem looks like there is something cached on the ColorUI.
Although each property grid is created in a different thread, the
ColorEditor created by reflection ()
is always the same.




嗯,可能。


你能发一个简短但完整的程序来演示

问题?


http://www.pobox.com/~skeet/csharp/complete.html 了解详情

我的意思是什么。


-

Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet

如果回复小组,请不要给我发邮件



Hmm, possibly.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


这篇关于propertygrid throw error&“在一个线程上创建的控件不能作为不同线程上的控件的父级。”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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