我想了解消息泵在 Windows 系统中的工作原理。我创建了一个控制台应用程序。我在这个应用程序中创建了新线程:
var thread = new Thread(MessagePump) {IsBackground = true};
_thread.Start();
消息泵送如下所示:
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
我使用另一个程序向该线程发送消息。我看到线程正在接收我的消息。我想了解这是如何发生的。我还没有为这个线程创建一个窗口。根据说明,您需要一个窗口来接收消息。