nsIEventTarget 编辑
xpcom/threads/nsIEventTarget.idl
Scriptable 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
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 |
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
.
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论