Is MFC UpdateAllViews blocking or non-blocking?
I have MFC code based on Framework Document View. I am using UpdateAllViews (nullptr, 0, nullptr) from the Document class to call the View OnDraw function.
void MyDocumentClass::MyFunction()
{
//.. Document code to create and process data
UpdateAllViews(nullptr,0,nullptr) // Invokes OnDraw
// When does program control reach this line?
}
My question, please tell me, is it blocking or not blocking the UpdateAllViews function when the programmatic control reaches the line next to UpdateAllViews ()? Does it get until it finishes executing the code in OnDraw (), or does it get there sooner?
source to share
UpdateAllViews is a blocking function that simply loops through each view and calls their OnUpdate function. This is not a "queue for later", and the return immediately calls the PostMessage function.
Like SendMessage, UpdateAllViews does not return until all code in each view has been executed. The OnUpdate function is complete. This is why doing something heavy like calling OnDraw directly or blocking I / O in UpdateAllViews / OnUpdate is generally a bad idea. The best practice is to invalidate some or all of the views based on the prompt parameters and let the framework call OnDraw on the next WM_PAINT.
source to share