Skip to content

Commit 722ada8

Browse files
authored
Use async main in How-To.md examples (#1246)
1 parent c76213f commit 722ada8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

docs/How-To.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ var parent = new RootCommand("parent")
6565
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:
6666

6767
```csharp
68-
static void Main(string[] args)
68+
static async Task Main(string[] args)
6969
{
7070
var rootCommand = new RootCommand();
7171

@@ -74,7 +74,7 @@ static void Main(string[] args)
7474
/* do something */
7575
});
7676

77-
rootCommand.InvokeAsync(args).Wait();
77+
await rootCommand.InvokeAsync(args);
7878
}
7979
```
8080

@@ -96,7 +96,7 @@ The process of creating these values based on command line input is known as mod
9696
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.
9797

9898
```csharp
99-
static void Main(string[] args)
99+
static async Task Main(string[] args)
100100
{
101101
var rootCommand = new RootCommand();
102102

@@ -105,7 +105,7 @@ static void Main(string[] args)
105105

106106
rootCommand.Handler = CommandHandler.Create<int, string>(DoSomething);
107107

108-
rootCommand.InvokeAsync(args).Wait();
108+
await rootCommand.InvokeAsync(args);
109109
}
110110

111111
public static void DoSomething(int anInt, string aString)

0 commit comments

Comments
 (0)