Browse Source

docs: Use `Timeout.Infinite` instead of -1 so that intent is clearer (#1443)

tags/2.3.0
Arnav Borborah GitHub 5 years ago
parent
commit
b6c981227d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 3 deletions
  1. +2
    -1
      samples/01_basic_ping_bot/Program.cs
  2. +2
    -1
      samples/02_commands_framework/Program.cs
  3. +2
    -1
      samples/03_sharded_client/Program.cs

+ 2
- 1
samples/01_basic_ping_bot/Program.cs View File

@@ -1,4 +1,5 @@
using System; using System;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Discord; using Discord;
using Discord.WebSocket; using Discord.WebSocket;
@@ -43,7 +44,7 @@ namespace _01_basic_ping_bot
await _client.StartAsync(); await _client.StartAsync();


// Block the program until it is closed. // Block the program until it is closed.
await Task.Delay(-1);
await Task.Delay(Timeout.Infinite);
} }


private Task LogAsync(LogMessage log) private Task LogAsync(LogMessage log)


+ 2
- 1
samples/02_commands_framework/Program.cs View File

@@ -1,5 +1,6 @@
using System; using System;
using System.Net.Http; using System.Net.Http;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Discord; using Discord;
@@ -45,7 +46,7 @@ namespace _02_commands_framework
// Here we initialize the logic required to register our commands. // Here we initialize the logic required to register our commands.
await services.GetRequiredService<CommandHandlingService>().InitializeAsync(); await services.GetRequiredService<CommandHandlingService>().InitializeAsync();


await Task.Delay(-1);
await Task.Delay(Timeout.Infinite);
} }
} }




+ 2
- 1
samples/03_sharded_client/Program.cs View File

@@ -1,4 +1,5 @@
using System; using System;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using _03_sharded_client.Services; using _03_sharded_client.Services;
using Discord; using Discord;
@@ -45,7 +46,7 @@ namespace _03_sharded_client
await client.LoginAsync(TokenType.Bot, Environment.GetEnvironmentVariable("token")); await client.LoginAsync(TokenType.Bot, Environment.GetEnvironmentVariable("token"));
await client.StartAsync(); await client.StartAsync();


await Task.Delay(-1);
await Task.Delay(Timeout.Infinite);
} }
} }




Loading…
Cancel
Save