Use async main in How-To.md examples (#1246)
This commit is contained in:
Родитель
c76213f608
Коммит
722ada8a23
|
@ -65,7 +65,7 @@ var parent = new RootCommand("parent")
|
|||
The simplest case for invoking your code, if you have a program so simple that it has no inputs beyond invocation itself, would look like this:
|
||||
|
||||
```csharp
|
||||
static void Main(string[] args)
|
||||
static async Task Main(string[] args)
|
||||
{
|
||||
var rootCommand = new RootCommand();
|
||||
|
||||
|
@ -74,7 +74,7 @@ static void Main(string[] args)
|
|||
/* do something */
|
||||
});
|
||||
|
||||
rootCommand.InvokeAsync(args).Wait();
|
||||
await rootCommand.InvokeAsync(args);
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -96,7 +96,7 @@ The process of creating these values based on command line input is known as mod
|
|||
The most common way that `System.CommandLine` performs model binding is to match option or argument names or aliases to the parameter names on a handler, or to the property names of complex objects passed to a handler. Parameters or properties are matched using a convention that matches camel-cased parameter names to kebab-cased option names. In this example, the option `--an-int` matches parameter `anInt` on the `DoSomething` method.
|
||||
|
||||
```csharp
|
||||
static void Main(string[] args)
|
||||
static async Task Main(string[] args)
|
||||
{
|
||||
var rootCommand = new RootCommand();
|
||||
|
||||
|
@ -105,7 +105,7 @@ static void Main(string[] args)
|
|||
|
||||
rootCommand.Handler = CommandHandler.Create<int, string>(DoSomething);
|
||||
|
||||
rootCommand.InvokeAsync(args).Wait();
|
||||
await rootCommand.InvokeAsync(args);
|
||||
}
|
||||
|
||||
public static void DoSomething(int anInt, string aString)
|
||||
|
|
Загрузка…
Ссылка в новой задаче