void Start() { if (pastDates == null) { pastDates = new List <Date>(); } Today = CreateStartDay(); onDayEnd += ArchiveDay; SetDayStartTime(); onDayStart += SetDayStartTime; canEndDay = true; }
private static async Task TimerTask() { while (!cancellationToken.IsCancellationRequested) { await Task.Delay(DaySpan, cancellationToken.Token); OnDayStart?.Invoke(null, new EventArgs()); if (cancellationToken.IsCancellationRequested) { return; } await Task.Delay(NightSpan, cancellationToken.Token); OnNightStart?.Invoke(null, new EventArgs()); if (cancellationToken.IsCancellationRequested) { return; } } }
void FireDayStart() { Debug.WriteLine($"Start of the day: {CurDate}"); ProcessSheduledActions(); OnDayStart.Invoke(); }