nsIEventTarget 编辑

xpcom/threads/nsIEventTarget.idlScriptable 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 66 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

ConstantValueDescription
DISPATCH_NORMAL0This 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_SYNC1

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

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:41 次

字数:5062

最后编辑:8年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文