In a single-threaded application, we know that when a program enters a function A that takes a long time to process, the system will not respond to various actions of the user, including closing the application, and the program will go into suspended animation, that is, the interface stops responding to other actions.
About C # can call Application.doevents () directly in the while loop;
1 BOOL Isstart=false23while (! Isstart)4{5 // event; 6 application.doevents (); 7 }89//Isstart can be changed to true on other buttons or the same button to end this loop
About C + + in the MFC interface, is also my current problems, can be resolved as follows:
1. As in C # above, convert application.doevents () into C + +: AfxGetApp ()->pumpmessage ();
2. Create a doevent function that also replaces the C # example:
1 //event handlers that are embedded in the loop so that other messages have a chance to be processed2 3 BOOL DoEvents ()4 {5 msg msg;6:: GetMessage (&msg,0,0,0);7 if(Msg.message = =wm_quit)8 {9 PostQuitMessage (msg.wparam);Ten returnFALSE; One } A Else - { -:: TranslateMessage (&msg); the::D ispatchmessage (&msg); - returnTRUE; - } -}
On the internet to look up a lot of information, basically is to create a doevent, today accidentally found the method 1
Share it to everyone. If you have any mistakes, you should correct them.
MFC or C # single button end While event loop