我可以使用多线程和使用gdi更新屏幕显示的功能吗? [英] Can I use multi-threading with functions that update the screen display using gdi?

查看:135
本文介绍了我可以使用多线程和使用gdi更新屏幕显示的功能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个音乐记谱法应用程序,最近又推出了一台配备Ryzen 1700处理器的新计算机 - 可用多个核心。我的记谱程序花费了大量时间来确保显示器准确地反映用户在分数中的位置。
基本上,当用户更改位置时,屏幕将被清除,并且依次绘制适合屏幕的每一分数。这涉及计算笔记和对象位置的多个函数,然后使用  gdi函数
绘制它们,例如  TextOut,  LineTo,Rectangle等。 由于我的屏幕更新功能在他们的计算中几乎只使用自动变量,而且通常只是读取数据,我想知道我是否可以通过为每个分数线启动一个新线程来有效地多线程我的屏幕更新
。  ;我可以看到的一个显而易见的问题是,如果重新绘制项目会对GDI的设备上下文进行更改 - 例如为文本选择不同的字体而不是笔记。 会不会出现
那种冲突或者我会更好地让睡觉的狗躺着?

I'm working on an application for music notation and recently got a new computer with a Ryzen 1700 processor -- many cores available. My notation program spends much of it's time making sure the display accurately reflects where the user is in the score. Basically, when the user changes position, the screen is cleared and each line of the score that will fit on the screen is drawn in turn. This involves multiple functions that calculate the position of notes and objects and then draw them using gdi functions such as TextOut, LineTo, Rectangle, etc.  Since my screen update functions use almost exclusively automatic variables in their calculations and are normally just reading data, I was wondering if I could efficiently multi-thread my screen update by initiating a new thread for each line of the score.  The obvious issue I can see would be if redrawing an item made a change to GDI's device context -- such as selecting a different font for text as opposed to notes.  Would there be someway around that kind of conflict or would I be better off letting sleeping dogs lie?

推荐答案

>会不会有某种程度的冲突?围绕这种冲突还是让睡觉的狗躺下来会更好?

>Would there be someway around that kind of conflict or would I be better off letting sleeping dogs lie?

多线程用户界面通常难以做好。我让那只狗睡着了。

Multi-threaded UIs are generally difficult to do well. I'd leave that dog asleep.

戴夫


这篇关于我可以使用多线程和使用gdi更新屏幕显示的功能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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