Re: [問題] Javascript利用TextArea當作Console
實作 thread,大概有這三種方法︰
1. 分段做
function createBatchProcess() {
var running, keys;
function start() {
if (running) {
return;
}
running = true;
...
...
keys = Object.keys(books);
setTimeout(next);
}
function next() {
if (!keys.length) {
return stop();
}
var key = keys.shift();
print(books[key]);
BatchTextImport(books[key], Word_Application);
setTimeout(next);
}
function stop() {
Word_Application.Quit();
Word_Application = null;
running = false;
}
return {
start: start
};
}
$("ProcessGo").click(createBatchProcess().start);
2. 用 generator
function* genProcess() {
...
...
for (var key in books) {
yield print(books[key]);
BatchTextImport(books[key], Word_Application);
}
Word_Application.Quit();
Word_Application = null;
}
var process = genProcess();
$("ProcessGo").click(function do(){
if (!process.next().done) {
setTimeout(do);
}
});
3. 用 Web Worker: http://is.gd/b0mcrA
--
(* ̄▽ ̄)/‧★*"`'*-.,_,.-*'`"*-.,_☆,.-*`
http://i.imgur.com/oAd97.png

--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.160.81.100
※ 文章網址: https://www.ptt.cc/bbs/Web_Design/M.1437392863.A.148.html
推
07/21 13:36, , 1F
07/21 13:36, 1F
→
07/21 13:40, , 2F
07/21 13:40, 2F
→
07/21 13:40, , 3F
07/21 13:40, 3F
→
07/21 13:57, , 4F
07/21 13:57, 4F
→
07/21 13:57, , 5F
07/21 13:57, 5F
→
07/22 08:24, , 6F
07/22 08:24, 6F
→
07/22 08:24, , 7F
07/22 08:24, 7F
→
07/22 08:24, , 8F
07/22 08:24, 8F
討論串 (同標題文章)
完整討論串 (本文為第 2 之 2 篇):
Web_Design 近期熱門文章
PTT數位生活區 即時熱門文章