For Each account In _accounts11
Dim newtask = account.readbalancesAsync()
newtask = newtask.ContinueWith(Sub() account.LogFinishTask("Getting Balances", starttime))
newtask = newtask.ContinueWith(Async Function() account.getOrdersAsync())
newtask = newtask.ContinueWith(Sub() account.LogFinishTask("Getting Orders", starttime))
tasklist.Add(newtask)
Next
Await Task.WhenAll(tasklist.ToArray)
Dim b = 1
基本上,对于每个帐户,我想做 account.readbalancesAsync 之后,我想做 account.getOrdersAsync()
我留下代码newtask.ContinueWith(Sub() account.LogFinishTask("Getting Balances", starttime))
以表明我知道 ContinueWith 是如何工作的。但是,在那之后,我需要继续执行另一项任务。
我该怎么做?
我想做的是这样的
For Each account In _accounts11
await account.readbalancesAsync()
account.LogFinishTask("Getting Balances", starttime)
await account.getOrdersAsync())
account.LogFinishTask("Getting Orders", starttime)
tasklist.Add(newtask)
Next
显然,如果我这样做,那么一个帐户必须等待另一个帐户完成。我希望所有帐户并行运行。
或者让我们看看这段代码
dim response1 = await client.GetAsync("http://example.com/");
dim response2 = await client.GetAsync("http://stackoverflow.com/");
说我这样做
dim newtask = client.GetAsync("http://example.com/").continueWith(....)
await newtask
我应该放什么......