Monday, June 3, 2024
174
rated 0 times [  177] [ 3]  / answers: 1 / hits: 73580  / 15 Years ago, tue, july 21, 2009, 12:00:00

I have a cpu intensive task that I need to run on the client. Ideally, I'd like to be able to invoke the function and trigger progress events using jquery so I can update the UI.



I know javascript does not support threading, but I've seen a few promising articles trying to mimic threading using setTimeout.



What is the best approach to use for this? Thanks.


More From » multithreading

 Answers
26

I had a similar problem to solve recently where i needed to keep my UI thread free while crunching some data to display.



I wrote a library Background.js to handle a few scenarios: a sequential background queue (based on the WorkerQueue library), a list of jobs where each is called on every timer, and an array iterator to help break up your work into smaller chunks. Examples and code here: https://github.com/kmalakoff/background



Enjoy!


[#99089] Thursday, July 16, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tristani

Total Points: 318
Total Questions: 95
Total Answers: 106

Location: Saint Lucia
Member since Wed, Feb 8, 2023
1 Year ago
;