Asynchronous method in while loop
Posted yuanjiangw
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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;
}
以上是关于Asynchronous method in while loop的主要内容,如果未能解决你的问题,请参考以下文章
Asynchronous_method_invocation 异步方法调用 让步 yielding
Asynchronous Methods for Deep Reinforcement Learning(A3C)
Async/Await - Best Practices in Asynchronous Programming
[Javascript] Run asynchronous functions in sequence using reduce
How does a single thread handle asynchronous code in JavaScript?
[XState] Invoking a Promise for Asynchronous State Transitions in XState