BBjAPI::postPriorityCustomEvent

Description

In BBj 6.0 and higher, this method posts a BBjCustomEvent at the beginning of the BBj event queue.

Syntax

Return Value

Method

void

postPriorityCustomEvent(string eventName, Object payload)

Parameters

Variable

Description

eventName

This name identifies the event that is being posted.

payload

This Object will be available from the event when the BBjEvent is retrieved from the BBj event queue.

Return Value

None.

Remarks

A BBjCustomEvent posted as a priority event using this method will appear at the beginning of the event queue and will be available before any event that is currently on the queue.

Example

rem 'This program prints a series of numbers in response to

rem 'the posting of custom events.  The order in which the
rem 'numbers are printed depends on whether the number is odd
rem 'or even. Odd numbers are posted as priority custom events
rem 'and printed right away.  The even numbers are put on the
rem 'queue as normal custom events and are printed after the
rem 'odd numbers have been printed.  The program clears the
rem 'custom event once it encounters a custom event with the
rem 'number 6, so the events for numbers 8 and 10 are never
rem 'handled.
rem 'Class for handling the custom event
class public CounterEventHandler

    rem 'The method that actually handles the event
    method public void handleEvent(BBjCustomEvent evt!)
        declare auto BBjNumber payload!
        payload! = evt!.getObject()

        rem 'clear the event handler once we encounter the number 6
        if ((payload! = 6)) then
            BBjAPI().clearCustomEventCallback(evt!.getName())
        endif
        print payload!
    methodend
classend
eventType$="COUNTER"

rem 'Set the custom event handler
BBjAPI().setCustomEventCallback(eventType$,new CounterEventHandler(),"handleEvent")

rem 'Dispatch 10 events. Post odd numbered events as priority events
rem 'and even numbers as normal custom events.
for i = 1 to 10
    if (mod(i,2)) then
        BBjAPI().postPriorityCustomEvent(eventType$,i)
    else
        BBjAPI().postCustomEvent(eventType$,i)
    endif
next i
process_events

See Also

BBjEvent

BBj Object Diagram for an illustration of the relationship between BBjObjects.