272
edits
No edit summary |
|||
| Line 224: | Line 224: | ||
| | ||
thread->Dispatch(event, NS_DISPATCH_NORMAL); | thread->Dispatch(event, NS_DISPATCH_NORMAL); | ||
== From JS == | |||
Threads and Thread Manager implement <code>nsIClassInfo</code>: | |||
function MyEvent() { | |||
} | |||
MyEvent.prototype = { | |||
QueryInterface: function(iid) { | |||
if (iid.equals(Components.interfaces.nsIRunnable) || | |||
iid.equals(Components.interfaces.nsISupports)) | |||
return this; | |||
throw Components.results.NS_ERROR_NO_INTERFACE; | |||
}, | |||
run: function() { | |||
// do stuff | |||
} | |||
}; | |||
| |||
function DispatchMyEvent() { | |||
var target = | |||
Components.classes["@mozilla.org/thread-manager;1"]. | |||
getService().currentThread; | |||
| |||
target.dispatch(new MyEvent(), target.DISPATCH_NORMAL); | |||
} | |||
== Remarks == | == Remarks == | ||
edits