HTML and CSS Reference
In-Depth Information
Figure 5-1. Creating the Chapter 5 project
In the second dialog select the Basic Project template and make sure the Razor view engine is selected.
Employing Web Workers
With more and more work being done on the client, making the client application multi-threaded becomes more
important. Fortunately, the use of web workers is a convenient way to accomplish that. Functions that are CPU
intensive or may take some time to complete can be executed on a background thread leaving the main UI thread
available to respond to user actions.
Web workers use a fairly simple concept. You create a worker and pass it a JavaScript file that defines its
execution. The web page can then communicate with the worker through messages. The worker implements the
onmessage event handler to respond to an incoming message from the page and uses the postMessage() function
to send data back to the caller. The caller must also handle the onmessage event to receive the messages from the
worker. This is illustrated in Figure 5-2 .
Web page
(UI thread)
(separate thread)
var worker = new Worker()
Search WWH ::

Custom Search