本文介绍了异步读取GUI消息队列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在寻找以任何方式异步读取GUI消息队列(使用回调)。


目前,我正在使用的软件目前使用  MsgWaitForMultipleObjectsEx
,带有标记  QS_ALLPOSTMESSAGE ,但这阻止了我不喜欢的线程(我想添加
async / await支持GUI框架)。


以下是我调查的选项:


  *存在" RegisterWaitForSingleObject"但不是"MsgRegisterWaitForSingleObject" ( 我需要的
) 


    *  有" SendMessageCallback"
但不是"GetMessageCallback" 


    *有" SetWindowsHookEx + WH_GETMESSAGE "
(但这似乎仅在你调用GetMessage时调用,这不是我想要的)


    *有像" MQReceiveMessage"这样的函数,但似乎无法从GUI消息队列中读取消息,或者至少I
没有找到任何信息。 / p>

有没有办法让其中一个选项有效,还是有其他我错过了?


如果不是,那不是一个好主意 实现此功能,因为越来越多的语言默认实现异步支持(async / await)?





解决方案

Hi,

I'm looking for any way to read the GUI message queue asynchronously (with a callback).

Currently, the software I'm working on currently uses MsgWaitForMultipleObjectsExwith the flag QS_ALLPOSTMESSAGE, but this blocks the thread which I don't like (I would like to add async/await support for a GUI framework) .

The following are the options I investigated:

  * There exists "RegisterWaitForSingleObject" but not "MsgRegisterWaitForSingleObject" (what I would need) 

   * There is "SendMessageCallback" but not "GetMessageCallback" 

   * There is "SetWindowsHookEx+WH_GETMESSAGE" (but this seems to be called only when you call GetMessage, which is not what I want)

    * There are the functions like "MQReceiveMessage", but it doesn't seem possible to read a message from the GUI message queue from it, or at least I didn't find any information.

Is there any way to make one of these options work, or is there another that I missed?

If not, wouldn't it be a good idea to implement this feature, as more and more languages implement asynchronous support by default (async/await)?


解决方案


这篇关于异步读取GUI消息队列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 08:53