简体   繁体   English

MFC主线程仅关注Dialog,需要处理从服务器接收的数据

[英]MFC Main thread only focus on Dialog, need to deal with the data received from server

My code will receive xml data from server, the data quite huge. 我的代码将从服务器接收xml数据 ,该数据非常庞大。 after finishing receiving the xml data from sever, my code want to continue to parse the xml data, however, I have no idea why the thread focus on the dialog to receive message from system to paint or do something else... NO WAY TO go back to the parsing code. 从服务器接收完xml数据后,我的代码想继续解析xml数据,但是,我不知道为什么线程集中在对话框上以从系统接收消息以进行绘制或执行其他操作...没办法回到解析代码。 however, if i close the dialog, it will go back the parsing code automatically? 但是,如果我关闭对话框,它将自动返回解析代码?

what is the problem? 问题是什么? please help me..... 请帮我.....

从Internet上获取数据时,对话框的上载消息正在消息循环中挂起。因为您说的是大数据,所以它挂起了您的应用程序。所有其他消息都放入了消息队列。一旦您的应用程序从挂起状态返回,所有消息最后出现在对话框中的WM_PAINT消息也处于挂起状态,该消息在挂起条件完成之后且在读取xmle文件之前执行。

You will need to perform the "receive and parse xml data" in a separate thread if you need the dialog to be responsive during that time. 如果您需要对话框在此期间响应,则需要在单独的线程中执行“接收并解析xml数据”。

Use CreateThread() to start a thread, you can check if the thread has terminated (and get the exit code of the thread) using GetExitCodeThread() . 使用CreateThread()启动线程,可以使用GetExitCodeThread()检查线程是否已终止(并获取线程的退出代码

Alternatively, you can use the MFC CWinThread class to do the same thing. 或者,您可以使用MFC CWinThread类来执行相同的操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM