mincheat 2014-05-05 05:51 采纳率: 0%
浏览 2314

线程消息队列的宽度问题

想知道windows下系统消息队列的大小,线程消息队列的大小,在网上找了下,据说线程消息队列默认只有可以保存8个消息。我自己做了下测试,如下
void CMainFrame::HandleWaitThread(LPVOID lParam)
{

MSG msg;

Sleep(30000);
while (true)
{
    if(GetMessage(&msg,0,0,0)) //get msg from message queue
    {
        TRACE(_T("wait              msg.message = %d\r\n"),msg.message);
    }
}

}

void CMainFrame::HandleSendThread(LPVOID lParam)
{
ASSERT(lParam);
CMainFrame* pDlg = reinterpret_cast(lParam);
while(1)
{
static long i = 0;
TRACE(_T("send msg.message = %d\r\n"),i);
pDlg->pWaitThread->PostThreadMessage(i,0,0);
i++;
Sleep(500);
}
}
send线程向wait线程不断post消息,一开始wait线程Sleep 30s,那么这短时间send线程发送了60次消息,30s后,wait线程还是可以把那60个消息打印出来,这就应该可以说明线程消息队列不只存8个了吧。另外,在测试的时候还发现一个问题,每次测试都会有wait线程丢失消息的现象,就是说总会有几个消息打印不出来(或者说没有接收到),这到底是怎么回事,请各位大神帮忙看看,3q

  • 写回答

1条回答

  • Eleven 2014-11-07 10:59
    关注

    MSDN上有说明:

    Windows 2000/XP: 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.

    评论

报告相同问题?

悬赏问题

  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
  • ¥15 钢筋实图交点识别,机器视觉代码
  • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
  • ¥50 400g qsfp 光模块iphy方案
  • ¥15 两块ADC0804用proteus仿真时,出现异常
  • ¥15 关于风控系统,如何去选择
  • ¥15 这款软件是什么?需要能满足我的需求
  • ¥15 SpringSecurityOauth2登陆前后request不一致
  • ¥15 禅道二次开发编辑版本,上传不了发行包