问题描述如下:
本人编写了两个对话框窗体程序A,B
程序A中创建了一个线程,线程仅仅在while循环中,使用postmessage发送自定义消息至B程序中,循环次数设置为10W次。
程序B中通过wndproc接收并处理程序A发送的消息。
在两个程序运行初期没有问题,但是程序A发送消息大概32000左右时,就不再进行消息发送了,并且查看了一下,发送消息的线程没有退出,请教高手这可能是什么原因引起的及解决方法。

解决方案 »

  1.   

    用CreateThread()?在while中创建的线程的话,要CloseHandle()
      

  2.   

    关于PostMessage MSDN有如下解释:Windows 2000: There is a limit of 10,000 posted messages per message queue. This limit should be sufficiently large. If your application exceeds the limit, it should be redesigned to avoid consuming so many system resources. To adjust this limit, modify the following registry key:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows\USERPostMessageLimit. The minimum acceptable value is 4000. 就是说一个线程的消息队列最大值是10000,如果这些消息没有被处理掉(消息队列满了),那么就没有办法发送了。