Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
var pathToWebWorkerScript = ROOT + 'Scripts/webworker.js';
var worker = new Worker(pathToWebWorkerScript);
worker.onmessage = function (e) {
if (e && e != null) {
// Do work
var messageParameters = { parameter1: '1', parameter2: '2', };
// Start the worker.
/* This is the code that runs the foreground thread. Firstly, we initialize a new Worker object with 1 parameter: the path to the script that will be run on the background. Note that I use a variable named ROOT to determine the first half of the path. Because I'm using ASP.NET MVC, I thought it would be useful to call a URL helper to make this thing work :*/
var ROOT = '@Url.Content("~/")';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment