-
Notifications
You must be signed in to change notification settings - Fork 483
Closed
Description
The call await new Command(x).Execute() which is called from within await async lambda, does not wait for the task completion and the next line is executed immediately.
The next code isn't working fine:
static void Main(string[] args)
{
RunOptions(args);
}
static void RunOptions(string[] args)
{
var parser= new Parser();
var result = parser.ParseArguments<Options>(args);
//note async x in lambda
result.WithParsed(async x => {
await new Command(x).Execute();
});
}
I think it is expected because it's against the principle use async all the way up
How to use async/await in result.WithParsed
I want to re-write the code to use asyn Main() in C#7.1
static async Task Main(string[] args)
{
await RunOptions(args);
}
static async Task RunOptions(string[] args)
{
//rewrite the code using result.WithParsed(...)
// or WithParsed don't support async/await
}
I find this example for MapResult , but i need to use .WithParsed`
Metadata
Metadata
Assignees
Labels
No labels