There is a function that can be performed for a long time. Screw the form. But it does not fully render. A good example with Timer did not find. Perhaps experts will tell you how to solve?

 // блокирую основную форму this->Enabled = false; // вызываю форму с текстом "Подождите..." F3=gcnew Form3(); F3->Show(this); // без этой строчки после закрытия формы основная прячется this->F3->Closed += gcnew EventHandler(this,&Form1::form2_Closed); // выполнение "тяжелой" функции grid = gridObj.getResolve(grid); // закрываю форму "Подождите..." this->F3->Close(); // разблокировал основную форму this->Enabled = true; 

As a result, Label does not render:

enter image description here

Is it possible to do something without a timer? Tell me an example solution for Visual C ++ with a timer.

    2 answers 2

    Well, in general, the second thread is needed here, if I correctly understood what you want. You will need to perform a function in a separate thread.

    Here is a random link to lessons on multithreading http://vscode.ru/prog-lessons/potoki-v-si-sharp.html

    I forgot one more thing: try to update the window (before the heavy function) in the WinApi way. InvlidateRect () + UpdateWindow ()

    • Thank! With InvlidateRect () + UpdateWindow () did not understand how to fasten. And at the expense of streams, I think it should be an easier option, as an option through the timer. - spy686
    • found similar for UpdateWindow () - Update (); - spy686

    It is necessary to add "F3-> Update ();" Decision:

     // блокирую основную форму this->Enabled = false; // вызываю форму с текстом "Подождите..." F3=gcnew Form3(); F3->Show(this); F3->Update(); // !!!!!!!!!!! // без этой строчки после закрытия формы основная прячется this->F3->Closed += gcnew EventHandler(this,&Form1::form2_Closed); // выполнение "тяжелой" функции grid = gridObj.getResolve(grid); // закрываю форму "Подождите..." this->F3->Close(); // разблокировал основную форму this->Enabled = true;