本文介绍了在 Nito.AsyncEx 中找不到 Bootstrapper 类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请参阅以下问题的答案:无法指定 '控制台应用程序 'Main' 方法上的 async' 修饰符

Please see the answer to the following question: Can't specify the 'async' modifier on the 'Main' method of a console app

我正在尝试使用 VB.NET 程序执行此操作.我已经使用 NUGET 添加了包,并且我确保添加了引用.请看下面的代码:

I am trying to do this with a VB.NET program. I have added the package using NUGET and I have ensured that the Reference is added. Please see the code below:

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 创建异步 main 方法?

The error is: Type BootStrapper is not found. I have used Intellisense to look at the types contained in Nito.AsyncEx and Bootstapper is not there? How do I create an asynchronous main method using VB.NET?

推荐答案

Bootstrapper 不是 AsyncEx 的一部分.AsyncContext 是:

Bootstrapper is not a part of AsyncEx. AsyncContext is:

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

这篇关于在 Nito.AsyncEx 中找不到 Bootstrapper 类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 20:37