Canceling Events

Services whose names are of the form Cancel_XX_Event must be used only to cancel events scheduled by the corresponding Schedule_XX_Event or Call_XX_Event service. It is an error to pass (for example) a thread event handle to Cancel_VM_Event.

Services which cancel events also allow zero to be passed as the event handle, which is simply ignored. The standard paradigm for scheduling, processing, and canceling events is as follows:

Scheduling the event:

mov         esi, OFFSET32 MyEvent
VMMCall Schedule_Global_Event
mov     hMyEvent, esi            ; Save handle for cancellation
 

Processing the event:

BeginProc MyEvent
mov     hMyEvent, 0   ; VERY FIRST THING is
                      ; to zero out the handle
;   .
;   .                   Do other event stuff
;   .
ret                   ; Finished with the event
EndProc MyEvent
 

Canceling the event:

xor      esi, esi             ; Atomically set hMyEvent to 0
xchg     hMyEvent, esi        ; and retrieve previous value
VMMCall  Cancel_Global_Event  ; Cancel if still outstanding