Asynchronous method in while loop

Asynchronous method in while loop

https://stackoverflow.com/questions/43064719/javascript-asynchronous-method-in-while-loop

let taskPool = new Promise(function(resolve, reject) {
resolve("Success!");
});
let that = this;
while (index < this.totalPieces) {
end = start + thisPartSize;
if (end > filesize) {
end = filesize;
thisPartSize = filesize - start;
}
taskPool.then(() => {
that.worker(start, end, index, thisPartSize);
});
index++;
start = end;
}

猜你喜欢

转载自www.cnblogs.com/yuanjiangw/p/12069845.html
今日推荐