多个Windows类是否需要多个Windows消息队列? [英] Do multiple windows classes require multiple windows message queues?

查看:105
本文介绍了多个Windows类是否需要多个Windows消息队列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我的应用程序具有多个Windows类-RegisterClass()函数调用-每个都具有不同的.lpfnWndProc过程,那么我是否需要多个线程和多个Windows消息队列,或者我应该能够使它与单个线程一起工作,并且一个Windows消息队列?

If my application has multiple windows classes - RegisterClass() function calls - each with a different .lpfnWndProc procedure, do I need multiple threads and multiple windows message queues, or should I be able to make that work with a single thread and a single windows message queue?

推荐答案

否.消息队列是一个.而且,即使您在流程中使用了许多线程,每个UI元素也只有一个UI线程.

除了线程之外,您还应该了解面向事件的UI技术是如何工作的.对于Windows,此知识围绕应用程序的消息循环的思想.这篇简短的文章将为您提供想法:
http://www.winprog.org/tutorial/message_loop.html [
—SA
No. The message queue is one. And one UI thread per all UI elements, even if you use many threads in the process.

In addition to threading, you should also understand how event-oriented UI technologies work. For windows, this knowledge is around the idea of the message loop of the application. This short article will give you the idea:
http://www.winprog.org/tutorial/message_loop.html[^].

Well, on a very advanced side, it is possible to have more than one UI thread each executing its independent UI with separate message queue, but this is hardly practical and hardly worth considering. (I experimented with this on Windows and Mac OS X, to resolve really tricky problem related to porting of the Windows-only application to multi-platform, and the port could operate on two different UIs at the same time. So, the experiments demonstrated that it is possible, but I mentioned about it just for completeness. Strictly speaking, this is possible, but hardly should be considered. You asked about "require" — no, multiple classes do not require it, not at all :-).)

—SA


这篇关于多个Windows类是否需要多个Windows消息队列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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