XPCOM:nsIThreadManager: Difference between revisions

Jump to navigation Jump to search
no edit summary
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
  }
};
&nbsp;
function DispatchMyEvent() {
  var target =
      Components.classes["@mozilla.org/thread-manager;1"].
      getService().currentThread;
  &nbsp;
  target.dispatch(new MyEvent(), target.DISPATCH_NORMAL);
}


== Remarks ==
== Remarks ==
272

edits

Navigation menu