84 |
|
|
85 |
|
{IEvents} |
86 |
|
procedure WaitForEvent; |
87 |
< |
procedure AsyncWaitForEvent(EventHandler: TEventHandler); |
87 |
> |
procedure AsyncWaitForEvent(EventHandler: TEventHandler); override; |
88 |
|
end; |
89 |
|
|
90 |
|
implementation |
125 |
|
{$ENDIF} |
126 |
|
inherited Create; |
127 |
|
{$IFDEF WINDOWS} |
128 |
< |
FEventHandler := CreateEvent(PSa,false,true,nil); |
128 |
> |
FEventHandler := CreateEvent(PSa,false,false,nil); |
129 |
|
{$ELSE} |
130 |
|
CreateGuid(GUID); |
131 |
|
FEventWaiting := TEventObject.Create(PSa,false,false,GUIDToString(GUID)); |
166 |
|
try |
167 |
|
if FOwner.FResultBuffer <> nil then |
168 |
|
Move(events[0], FOwner.FResultBuffer[0], Length); |
169 |
– |
{$IFDEF WINDOWS} |
170 |
– |
SetEvent(FEventHandler); |
171 |
– |
{$ELSE} |
172 |
– |
FEventWaiting.SetEvent; |
173 |
– |
{$ENDIF} |
169 |
|
finally |
170 |
|
FOwner.FCriticalSection.Leave |
171 |
|
end; |
172 |
+ |
// writeln('Set Event'); |
173 |
+ |
{$IFDEF WINDOWS} |
174 |
+ |
SetEvent(FEventHandler); |
175 |
+ |
{$ELSE} |
176 |
+ |
FEventWaiting.SetEvent; |
177 |
+ |
{$ENDIF} |
178 |
|
end; |
179 |
|
|
180 |
|
procedure TEventhandlerInterface.WaitForEvent; |
184 |
|
{$ELSE} |
185 |
|
FEventWaiting.WaitFor(INFINITE); |
186 |
|
{$ENDIF} |
187 |
+ |
// writeln('Event Wait Ends'); |
188 |
|
end; |
189 |
|
|
190 |
|
procedure TEventhandlerInterface.CancelWait; |
260 |
|
if FInWaitState then |
261 |
|
IBError(ibxeInEventWait,[nil]); |
262 |
|
|
261 |
– |
CreateEventBlock; |
263 |
|
FEventHandler := EventHandler; |
264 |
|
ReleaseIntf; |
265 |
|
with Firebird30ClientAPI do |
287 |
|
begin |
288 |
|
inherited Create(DBAttachment,DBAttachment,Events); |
289 |
|
FAttachmentIntf := DBAttachment.AttachmentIntf; |
289 |
– |
FAsyncEventCallback := TEventhandlerInterface.Create(self,'Async'); |
290 |
– |
FEventHandlerThread := TEventHandlerThread.Create(self,FAsyncEventCallback); |
290 |
|
FSyncEventCallback := TEventhandlerInterface.Create(self,'Sync'); |
291 |
|
end; |
292 |
|
|
303 |
|
|
304 |
|
procedure TFB30Events.AsyncWaitForEvent(EventHandler: TEventHandler); |
305 |
|
begin |
306 |
+ |
{Seems like we have to create a new callback object each time to avoid empty events} |
307 |
+ |
if assigned(FEventHandlerThread) then |
308 |
+ |
TEventHandlerThread(FEventHandlerThread).Terminate; |
309 |
+ |
if assigned(FAsyncEventCallback) then TEventhandlerInterface(FAsyncEventCallback).release; |
310 |
+ |
FAsyncEventCallback := TEventhandlerInterface.Create(self,'Async'); |
311 |
+ |
FEventHandlerThread := TEventHandlerThread.Create(self,FAsyncEventCallback); |
312 |
|
InternalAsyncWaitForEvent(EventHandler,FAsyncEventCallback); |
313 |
|
end; |
314 |
|
|