I am trying to use the Parallels library to delay the execution of a procedure. My first thought was to use Sleep for the duration I need but it doesn't seem a good idea. Then, I came up with this approach:

I am trying to use the Parallels library to delay the execution of a procedure. My first thought was to use Sleep for the duration I need but it doesn't seem a good idea. Then, I came up with this approach:

i:=10000;
repeat
task:=TTask.Create(procedure
begin
Sleep(1);
end);

task.Start;
TTask.WaitForAny([task]);
until i<10000;
Listbox1.Items.Add('10 Seconds');

in an effort to make the app responsive but it looks like the behaviour is the same. The app is totally blocked.

Does anyone have a procedure to share? or thoughts how to make this happen?

Thanks a lot.

Comments

  1. JH Jang The first is what I wanted and I did that with the same code you have. Actually Andrea Magni's code is very similar to this. Thank you all for the input

    ReplyDelete
  2. John Kouraklis
    For the "execute something in form F1 after I close F2" scenario, you can define a new message that F1 handles, that is PostMessage'd from F2.

    ReplyDelete
  3. Eivind Bakkestuen Is PostMessage cross-platform?

    ReplyDelete

Post a Comment