You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ReadMe.md
+26Lines changed: 26 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1039,9 +1039,14 @@ public class ConsoleAppContext
1039
1039
publicMethodInfoMethodInfo { get; }
1040
1040
publicIServiceProviderServiceProvider { get; }
1041
1041
publicIDictionary<string, object> Items { get; }
1042
+
1043
+
publicvoidCancel();
1044
+
publicvoidTerminate();
1042
1045
}
1043
1046
```
1044
1047
1048
+
`Cancel()` set `CancellationToken` to canceled. Also `Terminate()` set token to cancled and terminate process(internal throws `OperationCanceledException` immediately).
1049
+
1045
1050
ConsoleAppOptions
1046
1051
---
1047
1052
You can configure framework behaviour by ConsoleAppOptions.
@@ -1110,6 +1115,27 @@ public class MyCommand
1110
1115
1111
1116
You can set func to change this behaviour like `NameConverter = x => x.ToLower();`.
1112
1117
1118
+
Terminate handling in Console.Read
1119
+
---
1120
+
ConsoleAppFramework handle terminate signal(Ctrl+C) gracefully with `ConsoleAppContext.CancellationToken`. If your application waiting with Console.Read/ReadLine/ReadKey, requires additional handling.
1121
+
1122
+
```csharp
1123
+
// case of Console.Read/ReadLine, pressed Ctrl+C, Read returns null.
[dotnet run](https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-run) is useful for local development or execute in CI tool. For example in CI, git pull and execute by `dotnet run -- --options` is easy to manage and execute utilities.
0 commit comments