I would like to work with dotnet async Main method, having the following signature:
static async Task Main(string[] args) {
var parser = new Parser();
var parserResult = parser.ParseArguments<Options>(args);
var mainAsync = new MainAsync();
parserResult.WithParsed<Options>(async options => await mainAsync.Run(options).ConfigureAwait());
}
Run is defined like:
public async Task Run(Options options)
{
...
}
Problem is, my async methods behave strangely. They may work but can also simply terminate my program. It would seem I am doing something wrong, but I can't figure out what it is.
If I do this instead, there doesn't seem to be any problems, but I lose my async main method and some other stuff I have needs to be rewritten.
static void Main(string[] args) {
var parser = new Parser();
var parserResult = parser.ParseArguments<Options>(args);
var mainAsync = new MainAsync();
parserResult.WithParsed<Options>(options => mainAsync.Run(options).GetAwaiter().GetResult());
}
Why does the top-most Main fail in strange way and bottom one just works? Is CommandLineParser not async compatible?
I would like to work with dotnet async Main method, having the following signature:
Run is defined like:
Problem is, my async methods behave strangely. They may work but can also simply terminate my program. It would seem I am doing something wrong, but I can't figure out what it is.
If I do this instead, there doesn't seem to be any problems, but I lose my async main method and some other stuff I have needs to be rewritten.
Why does the top-most Main fail in strange way and bottom one just works? Is CommandLineParser not async compatible?