Link to home
Start Free TrialLog in
Avatar of kalliopi
kalliopi

asked on

Waiting On A Semiphore (semifore??)

It's a pretty simple question...

How do I wait on a semiphore in DELPHI?
Avatar of sarc
sarc
Flag of Germany image

I think, you mean a semAphore?

This might be easy - or difficult. To answer this question we need more information....

For example a "file semaphore":

One program writes a file (can be empty, but can contain information, too) when starting a specific operation. All other programs now know that this operation is in progress (and they are not allowed to interfere at the moment). If the program is ready, the file is deletet.

This is only ONE example of thousands for the use of semaphores. The range of usage goes from Database programming to the windows multitasking core itself and from files to registers...

On what kind of semaphore (I still think, you mean this) do you want to wait???


greetz
Carsten
The semifore (traffic light) may be simple boolean variable. When you waiting for it changed you need to give an ability to application to continue its work.

------
var Semifore : boolean;

procedure WaitForSemifore;
begin
    while not Semiphore
      do Application.ProcessMessages; // or Application.HandleMessage
end;

----
Igor.
ASKER CERTIFIED SOLUTION
Avatar of Lischke
Lischke

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kalliopi
kalliopi

ASKER

Mike,

Thanx.  That was exactly what I was looking for.  I've had to use "while true Application.ProcessMessages and it's just killing my CPU time.  Thanx much.  That's great.
Yup :-)