请参阅以下问题的答案:Can't specify the 'async' modifier on the 'Main' method of a console app
我正在尝试使用VB.NET程序。我已经使用NUGET添加了包,并确保添加了Reference。请参阅以下代码:
Imports Nito.AsyncEx
Public Class ScheduledTasks
Private Shared Async Sub MainAsync(args As String())
Dim bs As New Bootstrapper()
Dim list As VariantType = Await bs.GetList()
End Sub
End Class
错误是:找不到类型BootStrapper。我用Intellisense来查看Nito中包含的类型.AsyncEx和Bootstapper不存在?如何使用VB.NET创建异步主方法?
答案 0 :(得分:0)
Bootstrapper
不是AsyncEx的一部分。 AsyncContext
是:
Imports Nito.AsyncEx
Public Class Program
Private Shared Sub Main(args As String())
AsyncContext.Run(Function() MainAsync(args))
End Sub
Private Shared Function MainAsync(args As String()) As Task
...
End Function
End Class