简体   繁体   中英

Call Javascript function as a thread using Webworker

I have a html application which has a search functionality on a bunch of htmls

I have a method called searchAndPopulate(keyword) . this method is intended to find the results and populate the results and results counts. But the issue here with this javascript function is, it is not updating the counts and results in UI continuously as soon as each result processed, Instead it freezes the screen and throws results on a go at one time after all results are fetched. Am new to web worker, please help me how I can call this method using webworker to make it as a thread so that it will make a smooth UI experience with incremental results and counts shown to user. Please Give me a idea on how I can achieve it with webworker or any other possible way.

Note: the methods calls deferred methods inside it. and I have already tried giving small timeout between each process it is not working coz of deferred methods might be keep freezing the UI. Can't Post code coz it is a tangled part of a large code base

Any help would be highly appreciated

我发现本教程非常有帮助: http : //www.html5rocks.com/en/tutorials/workers/basics/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM