ProcessMessages and application use

I need to know if using ProcessMessages, which allows me to use the entire application, is legal.

Pseudocode:

The button for calling the main thread is a search.

procedure ButtonOnClick;
begin
    var1 = ExecuteSearch();
end;    

function ExecuteSearch:Something;
begin
 thread.StartThread;
 while thread.Finished do
 Application.ProcessMessages;
 result := something;
end;

When I use this construct, I can click on other parts of my software and use it. But I do not know how this works. And if it's safe.

+1
source share
2 answers

, OnTerminate , . Delphi , . Synchronize, , .

+2

, . . , . , . ProcessMessages , .

, ProcessMessages. , . , , .

, ProcessMessages, , . , . :

while MsgWaitForMultipleObjects(1, Thread.Handle, False, 
    INFINITE, QS_ALLEVENTS)=WAIT_OBJECT_0+1 do
  Application.ProcessMessages;

MsgWaitForMultipleObjects , :

  • . , .

, , .

+2

All Articles