如何让nodejs应用程序等待异步调用完成?
main.coffee:
hosts = require './suhosts'
dns = require 'dns'
async = require 'async'
data = {}
async.each hosts, (host, cb_e) ->
dns.lookup host, (err, address, family)-> data[host] = address
, () ->
console.log data
如果像coffee main.coffee
那样运行它,它将在完成工作之前退出。
答案 0 :(得分:2)
您没有拨打所需的SGrid1.ColumnByIndex(1).HorizontalAlign := TTextAlign.Leading;
回拨。
async.each