Skip to content

Commit cb701f3

Browse files
authored
Update the ReadMe to show we support await
1 parent 695e038 commit cb701f3

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

README.md

+5-11
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,16 @@ By default, it adds a "Modules" subdirectory of your application root to your PS
2222
Of course, what makes it interesting is that you can invoke PowerShell cmdlets from code behind as easily as this:
2323

2424
```csharp
25-
PoshConsole.ExecuteCommand("Get-ChildItem");
25+
PoshConsole.Invoke("Get-ChildItem");
2626
```
2727

28-
And the command/script that you invoke is displayed in the console along with it's output -- so in a graphical management interface, it provides you with a way to leverage your PowerShell investment and teach your users the command-line interface at the same time.
28+
And the command/script that you invoke is displayed in the console along with it's output -- so in a graphical management interface, it provides you with a way to leverage your PowerShell investment _and_ teach your users the command-line interface at the same time.
2929

30-
You can easily call a command and then populate a listbox in your UI with the results (as well as displaying the command and the output in the console pane):
30+
You can easily call a command with async await, and then populate a listbox in your UI with the results (as well as displaying the command and the output in the console pane):
3131

3232
```csharp
33-
PoshConsole.ExecuteCommand("Get-ADUser", onSuccessAction: users =>
34-
{
35-
Dispatcher.InvokeAsync(() =>
36-
{
37-
// Users is a collection of PSObject, let's unwrap the base objects:
38-
UserList.DataContext = users.Select(u => u.BaseObject);
39-
}
40-
});
33+
var users = await PoshConsole.InvokeAsync(new Command("Get-ADUser"));
34+
Dispatcher.InvokeAsync(() => UserList.DataContext = users.Select(u => u.BaseObject))
4135
```
4236

4337
There is, of course, much more you can do, and I'm just getting started, so there are plenty more features on the way, and I'm still debating a few of the design choices, if you'd like to voice an opinion.

0 commit comments

Comments
 (0)