ibec_WaitForEvent

The ibec_WaitForEvent function can be used to monitor events sent by the POST_EVENT command. It returns the event name if an event is fired or NULL if timeout is expired.

Syntax

 function ibec_WaitForEvent(Connection : variant; EventName : string; Timeout : cardinal) : variant;

Timeout should be specified in milliseconds. Timeout = 0 means infinitely waiting for event!

Example

Let's create triggers in our database which will post event

CREATE TRIGGER tr1 FOR customer
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
POST_EVENT 'new_customer';
END    
CREATE TRIGGER tr2 FOR customer
ACTIVE AFTER UPDATE POSITION 0
AS
BEGIN
IF (new.FIRSTNAME <> old.FIRSTNAME) THEN
POST_EVENT 'FIRSTNAME_changed';
END

Now we can check for that event in following example, with timeout of 10 sec specified for testing:

  execute ibeblock
  as
  begin
    try
      FBSrc  = ibec_CreateConnection(__ctFirebird,'DBName="localhost:D:\MYDB.FDB";
                                  ClientLib=fbclient.dll;
                                  user=SYSDBA; password=masterkey; names=UTF8; sqldialect=3');

      Res = ibec_WaitForEvent(FBSrc, 'FIRSTNAME_changed', 100000);
      if (Res is not null) then
        ibec_ShowMessage(Res);

    finally
      ibec_CloseConnection(FBSrc);
    end;
  end