Hi,

Here is a sample for Thread in Mozilla,

*<?xml version="1.0"?>*
*<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>*
*<window id="yourwindow" xmlns="
http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";>*
*<script type="text/javascript">*
*var main = Components.classes['@
mozilla.org/thread-manager;1'].getService().mainThread;*
*var background = Components.classes['@
mozilla.org/thread-manager;1'].getService().newThread(0);*

*var workingThread = function(threadID, number) {*
*  this.threadID = threadID;*
*  this.number = number;*
*  this.result = 0;*
*};*
*workingThread.prototype = {*
*  run: function() {*
*    try {*
*      // This is where the working thread does its processing work.      *
*      this.result = this.number;*
*      *
*      // When it's done, call back to the main thread to let it know*
*      // we're finished.*
*      *
*      main.dispatch(new mainThread(this.threadID, this.result),*
*        background.DISPATCH_NORMAL);*
*    } catch(err) {*
*      Components.utils.reportError(err);*
*    }*
*  },*
*  *
*  QueryInterface: function(iid) {*
*    if (iid.equals(Components.interfaces.nsIRunnable) ||*
*        iid.equals(Components.interfaces.nsISupports)) {*
*            return this;*
*    }*
*    throw Components.results.NS_ERROR_NO_INTERFACE;*
*  }*
*};*

*var mainThread = function(threadID, result) {*
*  this.threadID = threadID;*
*  this.result = result;*
*};*
*mainThread.prototype = {*
*  run: function() {*
*    try {*
*      // This is where we react to the completion of the working thread.*
*      alert('Thread ' + this.threadID + ' finished with result: ' +
this.result);*
*    } catch(err) {*
*      Components.utils.reportError(err);*
*    }*
*  },*
*  *
*  QueryInterface: function(iid) {*
*    if (iid.equals(Components.interfaces.nsIRunnable) ||*
*        iid.equals(Components.interfaces.nsISupports)) {*
*            return this;*
*    }*
*    throw Components.results.NS_ERROR_NO_INTERFACE;*
*  }*
*};*
*</script>*
*<label id="workingThread" value="workingThread" onclick="*
*    background.dispatch(new workingThread(1, 2),
background.DISPATCH_NORMAL);"/>*
*</window>*



Why when I press "workingThread" more than 3 or 4 times then FF closed?

Any Idea?
_______________________________________________
Project_owners mailing list
[email protected]
https://www.mozdev.org/mailman/listinfo/project_owners

Reply via email to