最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

完成异步功能时,在NodeJS中断开While循环[重复]

IT培训 admin 5浏览 0评论

完成异步功能时,在NodeJS中断开While循环[重复]

这个问题在这里已有答案:

  • Limited number of javascript promises is not working if running in infinite loop 1回答
回答如下:

如果您只想记录一次processing...,我会将代码更改为以下代码。

var statuslogged = false;
while (true) {
  if (!statuslogged) {
    console.log('processing...');
    statuslogged = true;
  }
  if (asyncdone) {
    console.log(result)
  }
}

完成异步功能时,在NodeJS中断开While循环[重复]

这个问题在这里已有答案:

  • Limited number of javascript promises is not working if running in infinite loop 1回答
回答如下:

如果您只想记录一次processing...,我会将代码更改为以下代码。

var statuslogged = false;
while (true) {
  if (!statuslogged) {
    console.log('processing...');
    statuslogged = true;
  }
  if (asyncdone) {
    console.log(result)
  }
}
发布评论

评论列表 (0)

  1. 暂无评论