一个线程创建之初是没有消息队列的

昨天帮人改一个程序,由于不知道以下的内容,走了很多弯路。。。

原文可以在msdn中搜索“About Messages and Message Queues ”找到:

The system maintains a single system message queue and one thread-specific message queue for each graphical user interface (GUI) thread. To avoid the overhead of creating a message queue for non–GUI threads, all threads are created initially without a message queue. The system creates a thread-specific message queue only when the thread makes its first call to one of the User or Windows Graphics Device Interface (GDI) functions.

windows维护着一个系统消息队列,以及分别为每个GUI线程维护一个各自的线程消息队列。为了避免非GUI线程的创建线程消息队列的开销,所有线程创建初始化时,均不创建消息队列。只有当线程第一次调用GDI函数时,系统才会为线程创建消息队列。所以那些非GUI线程是没有消息队列的。

 

关于消息队列更多的解释可以在如下地址找到(文章是从msdn翻译过来的):

http://blog.csdn.net/bichenggui/article/details/4677494

posted @ 2012-03-19 10:23  kcy-666  阅读(2013)  评论(0编辑  收藏  举报