Board index » delphi » TIBevents in D6 not working like in D5 with IBX 4.62

TIBevents in D6 not working like in D5 with IBX 4.62

Hi folks,

We are porting over to D6 (finally! :-) and are running into a problem with
TIBEvents not functioning like under D5 with IBX 4.62.

I apologize up front for being wordy.

Ent versions of both. D5 update 2 applied with IBX 4.62 and D6 update 2 applied
with IBX 6.03 installed.

We have an many events we register. Two events in particular actually change
based on what record we are using. We have run code like this:

for x := 0 to IBEvents1.Events.Count -1 do
   begin
   if pos('MyEvent',IBEvents1.Events[x]) > 0 then
      begin
      IBEvents1.Events.Delete(x);
      IBEvents1.Events.Add('MyEvent' + inttostr(recordnumber));
      break;
      end;
   end;

This has the effect of removing the one event and adding the new event for the
current record we are working with. We only see if changes are made to 'our'
record-not all records.

AutoRegsiter is set to FALSE, we explicitly call the IBEvents1.RegisterEvents
procedure once the database is connected.

We use firebird RC2. This works great for D5.

D6 is another matter.

Coded as above generates an error in gds32.dll. When the events.add is called. I
don't remember the error since I am writing this from home.

If I change the code as follows, it works, but seems to pound on the database
more...
for x := 0 to IBEvents1.Events.Count -1 do
   begin
   if pos('MyEvent',IBEvents1.Events[x]) > 0 then
      begin
      IBEvents1.Registered := False;//new line number 1
      IBEvents1.Events.Delete(x);
      IBEvents1.Events.Add('MyEvent' + inttostr(recordnumber));
      IBEvents1.Registered := True;//new line number 2
      break;
      end;
   end;

Ultimately, my question is why I need to add the unregister and reregister into
this code to make it work. I have 18 events registered and if I keep
unregistering and reregistering them all, that is a LOT of extra traffic to the
database. Is there something in the D5 IBX components that was making the
unregister of all events happen anyway without my knowing  about it?

This does work in D6 with update 1 and IBX 6.01 - meaning no erros are
generated, BUT, the events never seem to get trapped and the event code fired.

Thanks for any help anyone can offer.

Todd Asher
ash...@yadasystems.com

 

Re:TIBevents in D6 not working like in D5 with IBX 4.62


IBEvents between IBX 6.03 and IBX 4.63 has 2 lines different.  These two lines
were added to correctly return the EventCount.  Other than that there have been
no changes in IBEvents since 7/15 of last year.

These are the two changes

procedure TIBEventThread.DoEvent;
begin
  Parent.FOnEventAlert(Parent, Parent.FEvents[((EventGroup * IB_MAX_EVENT_BLOCK)
+ WhichEvent)], StatusVectorArray[WhichEvent], FCancelAlerts)
end;

to

procedure TIBEventThread.DoEvent;
begin
  Parent.FOnEventAlert(Parent, Parent.FEvents[((EventGroup * IB_MAX_EVENT_BLOCK)
+ WhichEvent)], CountForEvent, FCancelAlerts)
end;

and

 CountForEvent := StatusVectorArray[WhichEvent];

is right before the Synchronize call in TIBEventThread.ProcessEvents.  That is
all that has changed since 4.63.  There is no way I can see that this would
cause any problem.  The only other change I can see is correctly setting
Registered on RegisterEvents.

IBEvents has barely changed in the past year and there is no difference between
the D6 code and the current D5 code.

Quote
RayZor{*word*128}wrote:

> Hi folks,

> We are porting over to D6 (finally! :-) and are running into a problem with
> TIBEvents not functioning like under D5 with IBX 4.62.

--
Jeff Overcash (TeamB)
      (Please do not email me directly unless  asked. Thank You)
This sad little lizard told me that he was a brontosaurus on his mother's
side.  I did not laugh; people who boast of ancestry often have little else
to sustain them.  Humoring them costs nothing and ads to happiness in
a world in which happiness is in short supply.   (RAH)

Re:TIBevents in D6 not working like in D5 with IBX 4.62


After doing some more research today at work, I discovered the following:

The prolblem only shows up if there are enough events to cause 2 threads to be in
existence and then only if I delete one event and then add an event.

If I just add an event without deleting an event, no error occurs.

The error happens in the TIBEventThread.UnregisterEvents during the
isc_free(EventBuffer);

The EventBuffer is nil when we get into that procedure during the addition of the
new event.

Now, here is something interesting. If I put a sleep(1) between the delete and the
add, everything works great! The EventBuffer is not nil. This seems to be a thread
timing issue of some sort.

I have another real question here. When I delete an event it seems that the entire
set of events is becoming unregistered, the event is deleted, then the entire set of
events is getting re-registered. The same thing happens when I add an event, all are
unregistered, event is added, all are re-registered. Am I understanding this
correctly? If so, then manually unregistering then deleting and adding, then
manually re-registering seems the way to go.

Thanks for anyone's insight or interest.

Todd

Quote
RayZor{*word*128}wrote:
> Hi folks,

> We are porting over to D6 (finally! :-) and are running into a problem with
> TIBEvents not functioning like under D5 with IBX 4.62.

> I apologize up front for being wordy.

> Ent versions of both. D5 update 2 applied with IBX 4.62 and D6 update 2 applied
> with IBX 6.03 installed.

> We have an many events we register. Two events in particular actually change
> based on what record we are using. We have run code like this:

> for x := 0 to IBEvents1.Events.Count -1 do
>    begin
>    if pos('MyEvent',IBEvents1.Events[x]) > 0 then
>       begin
>       IBEvents1.Events.Delete(x);
>       IBEvents1.Events.Add('MyEvent' + inttostr(recordnumber));
>       break;
>       end;
>    end;

> This has the effect of removing the one event and adding the new event for the
> current record we are working with. We only see if changes are made to 'our'
> record-not all records.

> AutoRegsiter is set to FALSE, we explicitly call the IBEvents1.RegisterEvents
> procedure once the database is connected.

> We use firebird RC2. This works great for D5.

> D6 is another matter.

> Coded as above generates an error in gds32.dll. When the events.add is called. I
> don't remember the error since I am writing this from home.

> If I change the code as follows, it works, but seems to pound on the database
> more...
> for x := 0 to IBEvents1.Events.Count -1 do
>    begin
>    if pos('MyEvent',IBEvents1.Events[x]) > 0 then
>       begin
>       IBEvents1.Registered := False;//new line number 1
>       IBEvents1.Events.Delete(x);
>       IBEvents1.Events.Add('MyEvent' + inttostr(recordnumber));
>       IBEvents1.Registered := True;//new line number 2
>       break;
>       end;
>    end;

> Ultimately, my question is why I need to add the unregister and reregister into
> this code to make it work. I have 18 events registered and if I keep
> unregistering and reregistering them all, that is a LOT of extra traffic to the
> database. Is there something in the D5 IBX components that was making the
> unregister of all events happen anyway without my knowing  about it?

> This does work in D6 with update 1 and IBX 6.01 - meaning no erros are
> generated, BUT, the events never seem to get trapped and the event code fired.

> Thanks for any help anyone can offer.

> Todd Asher
> ash...@yadasystems.com

Other Threads