mirror of
https://github.com/NoiTheCat/BirthdayBot.git
synced 2024-11-21 21:54:36 +00:00
Modify debug/release delay behavior
This commit is contained in:
parent
0d93936bc8
commit
20834b677a
1 changed files with 11 additions and 4 deletions
|
@ -12,9 +12,20 @@ namespace BirthdayBot
|
|||
class BackgroundServiceRunner
|
||||
{
|
||||
// Amount of idle time between each round of task execution, in seconds.
|
||||
#if DEBUG
|
||||
// Amount of idle time between each round of task execution, in seconds.
|
||||
const int Interval = 10;
|
||||
|
||||
// Amount of time between start and first round of processing, in seconds.
|
||||
const int StartDelay = 15;
|
||||
#else
|
||||
// Amount of idle time between each round of task execution, in seconds.
|
||||
const int Interval = 8 * 60;
|
||||
|
||||
// Amount of time between start and first round of processing, in seconds.
|
||||
const int StartDelay = 60;
|
||||
#endif
|
||||
|
||||
|
||||
const string LogName = nameof(BackgroundServiceRunner);
|
||||
|
||||
|
@ -53,14 +64,10 @@ namespace BirthdayBot
|
|||
/// </summary>
|
||||
private async Task WorkerLoop()
|
||||
{
|
||||
#if !DEBUG
|
||||
// Start an initial delay before tasks begin running
|
||||
Program.Log(LogName, $"Delaying first background execution by {StartDelay} seconds.");
|
||||
try { await Task.Delay(StartDelay * 1000, _workerCancel.Token); }
|
||||
catch (TaskCanceledException) { return; }
|
||||
#else
|
||||
Program.Log(LogName, "Debug build - skipping initial processing delay.");
|
||||
#endif
|
||||
while (!_workerCancel.IsCancellationRequested)
|
||||
{
|
||||
// Initiate background tasks
|
||||
|
|
Loading…
Reference in a new issue