Last active
January 12, 2018 15:44
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', }; | |
worker.postMessage(messageParameters); | |
// 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