Execute Background Task In Javascript

后端 未结 9 1607
迷失自我
迷失自我 2020-11-28 22:39

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

9条回答
  •  春和景丽
    2020-11-28 23:13

    Depending on what your requirements are, you may get off easily by using Gears. Gears supports threads, which could do what you want.

    As you mentioned, setTimeout is the other option. Depending on the type of your task, you can hand off each iteration of a loop to a separate setTimeout call with some spacing in between, or you may need to separate pieces of your main algorithm into separate functions which can be called one by one in a same manner as you'd call each iteration.

提交回复
热议问题