HTML5 Web Workers
Web Workers objects act as if they had an implicit MessagePort associated with them. This port is part of a channel that is set up when the worker is created and never be garbage collected before the Web Workers object. Only DedicatedWorker is supported.
| Sample - Using HTML5 Web Worker Sample that demonstrates how to use the HTML5 Web Workers API [BlackBerry Developer Resource Center]. | 
Supported Platform(s)
- BlackBerry OS 5.0+
- BlackBerry PlayBook
- Ripple Emulator
| API | OS 5.0 | OS 6.0 | OS 7.0 | PlayBook | Ripple | 
|---|---|---|---|---|---|
| Worker | Y | Y | Y | Y | Y | 
| onmessage | Y | Y | Y | Y | Y | 
| postMessage | Y | Y | Y | Y | Y | 
| applicationCache | Y | Y | Y | Y | 
Configuration Document Settings
To use all of the API described for this object, you must ensure the following settings are in your configuration document:
This API does not require a <feature> element to be declared in the configuration document of your BlackBerry WebWorks Application.| Permission Elements (PlayBook Only) | 
|---|
| This API does not require a <permission> element to be declared in the configuration document of your BlackBerry WebWorks Application. | 
Worker
| Worker (fileName : String) | 
Supported Platform(s)
- BlackBerry OS 5.0+- BlackBerry PlayBook
- Ripple Emulator
Description
Creates a new Worker object.
| Parameter | Type | Description | 
|---|---|---|
| fileName | String | The name of the javascript file to be executed by the worker. | 
onmessage
| void onmessage([messageText: String], [senderId: String], [messageObject: Object]) | 
Supported Platform(s)
- BlackBerry OS 5.0+- BlackBerry PlayBook
- Ripple Emulator
Description
The onmessage is the event handler as IDL attributes to Web Workers ojbect.
| Parameter | Type | Description | 
|---|---|---|
| messageText | 
                                    
                                        String
                                    
                                     Optional  | 
                                text message. | 
| senderId | 
                                    
                                        String
                                    
                                     Optional  | 
                                sender ID. | 
| messageObject | 
                                    
                                        Object
                                    
                                     Optional  | 
                                message object when send. | 
postMessage
| void postMessage(message : Object) | 
Supported Platform(s)
- BlackBerry OS 5.0+- BlackBerry PlayBook
- Ripple Emulator
Description
The postMessage() method on Web Workers objects invoked the method of the same name on the port, with the same arguments, and returned the same return value.
| Parameter | Type | Description | 
|---|---|---|
| message | Object | A message to post when worker is created. | 
Code Example(s)
Main script:
<script type="text/javascript">
  var worker = new Worker('doWork.js');
  worker.addEventListener('message', function(e) {
       console.log('Worker said: ', e.data);
   }, false);
</script>
doWork.js (the worker):
  self.addEventListener('message', function(e) {
       self.postMessage(e.data);
   }, false);
	
    
            Properties:
| Property | Type | Description | Supported Platform(s) | 
|---|---|---|---|
| applicationCache | ApplicationCache | 
                            The ApplicationCache object associated with this worker
                            
                                 | 
                        
                        
                            
                                
                                     - BlackBerry OS 6.0+
                                     - BlackBerry PlayBook - Ripple Emulator  | 
                    
            
            Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 30 2012 13:31:21 GMT-0500 (EST)