线程逻辑问题 [英] Thread Logic Question

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

问题描述

全部,


我有一个UI表单,调用一个类对象,其中包含一个定时器,

通常会向屏幕绘制密集信息(~30 fps) )。

绘图在主UI线程上调用。我需要用户能够在绘图发生时与UI进行交互(动态

更改绘图属性)。由于绘图是在主要的

UI线程上进行的,因此UI表单一直没有收到用户控制事件

(如果有的话)。


有没有人对如何建模这个场景有一些建议,以便

我可以在UI表单上接收事件但是继续绘制?我将如何在C#中解决这个问题?谢谢。

All,

I have a UI form calling a class object that contains a timer that
routinely draws intensive information to the screen (~30 fps). The
drawing is invoked on the main UI thread. I need the user to be able
to interact with the UI while the drawing is happening (dynamically
change drawing properties). Since the drawing is happening on the main
UI thread, the UI form doesn''t receive the user control events
consistently (if at all).

Does anyone have some suggestions on how to model this scenario so that
I can receive events on the UI form but continue to draw? How would I
tackle this in C#? Thanks.

推荐答案

嗨乔丹,


有一件事你可以尝试使用剪辑矩形一次仅更新显示的单个部分。当您无效

时,显示只会使已变为脏的特定区域无效。


我还会尝试提供最有效的绘图代码你可以。


另一种选择可能就是使用Managed DirectX。


-

Dave Sexton


" Jordan" < jo *********** @ gmail.com在消息新闻中写道:11 ********************** @ h48g2000cwc.googlegr oups .com ...
Hi Jordan,

For one thing you could try using the clip rectangle to update only a single portion of the display at a time. When you Invalidate
the display only invalidate specific regions that have become "dirty".

I would also try to come up with the most effecient drawing code that you can.

Another option might be to just use Managed DirectX.

--
Dave Sexton

"Jordan" <jo***********@gmail.comwrote in message news:11**********************@h48g2000cwc.googlegr oups.com...

全部,


我有一个UI表单调用一个类对象,其中包含一个

通常会向屏幕绘制密集信息(~30 fps)。

绘图在主UI线程上调用。我需要用户能够在绘图发生时与UI进行交互(动态

更改绘图属性)。由于绘图是在主要的

UI线程上进行的,因此UI表单一直没有收到用户控制事件

(如果有的话)。


有没有人对如何建模这个场景有一些建议,以便

我可以在UI表单上接收事件但是继续绘制?我将如何在C#中解决这个问题?谢谢。
All,

I have a UI form calling a class object that contains a timer that
routinely draws intensive information to the screen (~30 fps). The
drawing is invoked on the main UI thread. I need the user to be able
to interact with the UI while the drawing is happening (dynamically
change drawing properties). Since the drawing is happening on the main
UI thread, the UI form doesn''t receive the user control events
consistently (if at all).

Does anyone have some suggestions on how to model this scenario so that
I can receive events on the UI form but continue to draw? How would I
tackle this in C#? Thanks.



Jordan,


我的猜测是你调用一个方法在你的主要表格中

然后完成所有绘图逻辑。


我建议如果可能的话将这种方法分解为

较小的零件,然后调用每个零件,这样你就可以对你的应用程序有一些

响应。


希望这有帮助。


-

- Nicholas Paldino [.NET / C#MVP]

- mv*@spam.guard.caspershouse.com


" Jordan" < jo *********** @ gmail.comwrote in message

news:11 ******************* ***@h48g2000cwc.googlegr oups.com ...
Jordan,

My guess is that you make one call to a method in your main form which
then does all the drawing logic.

What I would recommend is breaking up that method, if possible, into
smaller parts, and then calling each of those, so that you can have some
responsiveness to your app.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Jordan" <jo***********@gmail.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...

全部,


我有一个UI表单,呼叫一个包含计时器的类对象,该计时器通常会向屏幕绘制密集信息(~30 fps)。

绘图在主UI线程上调用。我需要用户能够在绘图发生时与UI进行交互(动态

更改绘图属性)。由于绘图是在主要的

UI线程上进行的,因此UI表单一直没有收到用户控制事件

(如果有的话)。


有没有人对如何建模这个场景有一些建议,以便

我可以在UI表单上接收事件但是继续绘制?我将如何在C#中解决这个问题?谢谢。
All,

I have a UI form calling a class object that contains a timer that
routinely draws intensive information to the screen (~30 fps). The
drawing is invoked on the main UI thread. I need the user to be able
to interact with the UI while the drawing is happening (dynamically
change drawing properties). Since the drawing is happening on the main
UI thread, the UI form doesn''t receive the user control events
consistently (if at all).

Does anyone have some suggestions on how to model this scenario so that
I can receive events on the UI form but continue to draw? How would I
tackle this in C#? Thanks.



戴夫,


感谢您的回复。我正在使用托管OpenGL处理​​

绘图,因此整个屏幕都在更新。我实际上正在为一个OpenGL应用程序写一个

扩展名,所以我对渲染上下文的控制是

有限。

Dave Sexton写道:
Dave,

Thanks for your response. I''m using managed OpenGL to handle the
drawing so the entire screen is being updated. I''m actually writing an
extension to an OpenGL app so my control over the rendering context is
limited.
Dave Sexton wrote:

嗨乔丹,


首先,您可以尝试使用剪辑矩形更新显示器的单个部分一次。当您无效

时,显示只会使已变为脏的特定区域无效。


我还会尝试提供最有效的绘图代码你可以。


另一种选择可能就是使用Managed DirectX。


-

Dave Sexton


" Jordan" < jo *********** @ gmail.com在消息新闻中写道:11 ********************** @ h48g2000cwc.googlegr oups .com ...
Hi Jordan,

For one thing you could try using the clip rectangle to update only a single portion of the display at a time. When you Invalidate
the display only invalidate specific regions that have become "dirty".

I would also try to come up with the most effecient drawing code that you can.

Another option might be to just use Managed DirectX.

--
Dave Sexton

"Jordan" <jo***********@gmail.comwrote in message news:11**********************@h48g2000cwc.googlegr oups.com...

全部,


我有一个UI表单调用一个类对象,其中包含一个

通常会向屏幕绘制密集信息(~30 fps)。

绘图在主UI线程上调用。我需要用户能够在绘图发生时与UI进行交互(动态

更改绘图属性)。由于绘图是在主要的

UI线程上进行的,因此UI表单一直没有收到用户控制事件

(如果有的话)。


有没有人对如何建模这个场景有一些建议,以便

我可以在UI表单上接收事件但是继续绘制?我将如何在C#中解决这个问题?谢谢。
All,

I have a UI form calling a class object that contains a timer that
routinely draws intensive information to the screen (~30 fps). The
drawing is invoked on the main UI thread. I need the user to be able
to interact with the UI while the drawing is happening (dynamically
change drawing properties). Since the drawing is happening on the main
UI thread, the UI form doesn''t receive the user control events
consistently (if at all).

Does anyone have some suggestions on how to model this scenario so that
I can receive events on the UI form but continue to draw? How would I
tackle this in C#? Thanks.


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

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