Here is one class with 1 method,
public class ApiService
{
public async Task StartAsync()
{
await _webHost.StartAsync();
}
}
Now trying to call above class/method like below,
public static async Task Main(string[] args)
{
HostFactory.Run(
configuration =>
{
configuration.Service<ApiService>(
service =>
{
service.ConstructUsing(x => new ApiService());
service.WhenStarted(x => x.StartAsync());
});
configuration.RunAsLocalSystem();
});
}
If I'm putting await
like this, it's giving error, where to put async/await here?
service.WhenStarted(x => await x.StartAsync());