Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions docs/core/docker/snippets/App/Program.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
var counter = 0;
var max = args.Length is not 0 ? Convert.ToInt32(args[0]) : -1;

while (max is -1 || counter < max)
// If a number is passed as a command-line argument,
// it will be used as the maximum counter value.
var max = args.Length > 0 && int.TryParse(args[0], out var parsedMax)
? parsedMax
: -1;

// Run indefinitely if no max value is provided
while (max == -1 || counter < max)
{
Console.WriteLine($"Counter: {++counter}");

await Task.Delay(TimeSpan.FromMilliseconds(1_000));
// Wait for one second between iterations
await Task.Delay(TimeSpan.FromSeconds(1));
}