-2
Public Shared Async Function getMarketDetailFromAllExchangesAsync() As Task
    Dim taskList = New List(Of Task)
    For Each account In uniqueAccounts()
        Dim newtask = account.Value.getMarketInfoAsync()
        taskList.Add(newtask)

    Next
    Await Task.WhenAll(taskList.ToArray)

    Dim b = 1
End Function

代码工作得很好。

但是,我想在每次完成任务时记录

所以我做了

        newtask.ContinueWith(Async Function(x) LogEvents(account.ToString))

LogEvents 是一个正常的功能。我有 2 个错误

在此处输入图像描述

我应该怎么做?

4

1 回答 1

0

我是这样做的

Public Shared Async Function getMarketDetailFromAllExchangesAsync() As Task
    Dim taskList = New List(Of Task)
    Dim starttime = jsonHelper.currentTimeStamp
    LogEvents("Start Getting Market Detail of All")
    For Each account In uniqueAccounts().Values
        Dim newtask = account.getMarketInfoAsync().ContinueWith(Sub() account.LogFinishTask("GetMarketDetail", starttime))
        taskList.Add(newtask)
        'newtask.ContinueWith(Sub() LogEvents(account.ToString))
    Next
    Await Task.WhenAll(taskList.ToArray)
    Dim b = 1
End Function

如果有人知道如何在没有 lambda 的情况下这样做,那就太好了。

于 2019-04-28T17:07:27.940 回答