Hello everyone,
In this post it might not be as interesting. I created a "while" loop with the purpose of continual runtime of the application until it closes. However, I came to a conundrum. In this "while" loop-
01: while(true)
02: {
03: if(PeekMessage(&msg, NULL, 0,0, PM_REMOVE))
04: {
05: if(msg.message == WM_QUIT)
06: {
07: TranslateMessage(&msg);
08: DispatchMessage(&msg);
09: break;
10: }
11: }
12: else
13: {
14: AppIterate();
15: TranslateMessage(&msg);
16: DispatchMessage(&msg);
17: }
18: }//Close while
19: //return (int)msg.wParam;
20: return (int)msg.wParam;
21: }//Close primary if statement
It is located in the body of the WinMain. Now, here is the question that gives me a round about. Please take a look at lines 7 through 9. I placed a break after TranslateMessage and DispatchMessage. Before, I have always placed a break before the two functions until just recently. Now, if I were to place a break before translate and dispatch then compile like so -
05: if(msg.message == WM_QUIT)
06: {
07: Break;
08: TranslateMessage(&msg);
09: DispatchMessage(&msg);
10: }
If the message was true and breaks out of the while loop before going through the translate and dispatch functions, wouldn't the application continue to run even though it is actually closed?(Hence it goes into and infinite loop that would not quit until the memory is depleted and goes into memory dump mode until you have to manually post a quit message for the application.)You have probably guessed I compiled and ran the application. In result this is what happened. Luckily, to my knowledge, nothing serious has happened. If anyone knows another approach to this deadly loop. It is a great solution to this mystery. Thanks in advance.