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?

+3


source to share


2 answers


UpdateAllViews is a non-blocking function that simply calls OnUpdate for each view. The OnUpdate function usually invalidates the view, which will subsequently call OnDraw. UpdateAllViews returns after invalidation and before picture.



+6


source


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.

+1


source







All Articles