Reputation: 9
If I use delphi ShowMessage or MessageDlg when the message is shown the program wait the click in the button and I wouldn't like that the program blocks himself. I need to show a message where I write that the program is searching, but as long as the message is shown the search doesn't start.. What can I do?
Thanks, Jack
ShowMessage('Sto ricercando . . .');
if (cartellaSorgente[Length(cartellaSorgente)] <> '\') then
begin
// do the research
end;
Upvotes: 0
Views: 894
Reputation: 612993
ShowMessage
displays a modal dialog. This means that the call to ShowMessage
does not return until the dialog is closed.
Your problem is that you wish to execute a long-running task without blocking the UI. The way to achieve that is to put the long-running task, the search, into a separate thread. Send messages from the search thread to the UI thread to allow the UI to inform the user of progress.
Upvotes: 5