Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

nsIEventTarget

A target for events. Events may be sent to this target from any thread by calling the dispatch method. Implement this interface in order to support receiving events from other threads.
1.0
28
Introduced
Gecko 1.6
Inherits from: nsISupports Last changed in Gecko 1.9 (Firefox 3)

Method overview

void dispatch(in nsIRunnable event, in unsigned long flags);
boolean isOnCurrentThread();
void postEvent(in PLEventPtr aEvent); Native code only! Obsolete since Gecko 1.9

Constants

Dispatch flags

Constant Value Description
DISPATCH_NORMAL 0 This flag specifies the default mode of event dispatch, whereby the event is simply queued for later processing. When this flag is specified, dispatch() returns immediately after the event is queued.
DISPATCH_SYNC 1

This flag specifies the synchronous mode of event dispatch, in which the dispatch() method does not return until the event has been processed.

Note: Passing this flag to dispatch may have the side-effect of causing other events on the current thread to be processed while waiting for the given event to be processed.

Methods

Requires Gecko 1.9 (Firefox 3)

dispatch()

Dispatches an event to this event target. This function may be called from any thread, and it may be called re-entrantly.

void dispatch(
  in nsIRunnable event,
  in unsigned long flags
);
Parameters
event
The event to dispatch.
flags
The dispatch flags modifying the event.
Exceptions thrown
NS_ERROR_UNEXPECTED
Indicates that the thread is shutting down and has finished processing events, so this event would never run and has not been dispatched.
NS_ERROR_INVALID_ARG
Indicates that event is null.

isOnCurrentThread()

Check to see if this event target is associated with the current thread.

boolean isOnCurrentThread();
Parameters

None.

Return value

Returns true if events dispatched to this event target will run on the current thread (that is, the thread calling this method). If events dispatched to this target will be processed on another thread, returns false.

Native code only!

postEvent

Obsolete since Gecko 1.9 (Firefox 3)
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

Method for posting an asynchronous event to the event target. If this method succeeds, then the event will be dispatched on the target thread.

void postEvent(
  in PLEventPtr aEvent
);
Parameters
aEvent
The event to dispatched.

Document Tags and Contributors

 Contributors to this page: Sheppy, trevorh, JorisW
 Last updated by: Sheppy,