async void OnTimerElapsed(object sender, ElapsedEventArgs e) { if (_timer != null) { _timer.Enabled = false; } DateTime = TimeZoneInfo.ConvertTime(DateTime.Now, DateTimeService.CentralTimeZone); TimeRemaining = ShowTime.Subtract(DateTime); bool reenableTimer = true; bool alreadyStarted = TimeRemaining.Ticks < 0; if (alreadyStarted) { // Show is over if (TimeRemaining.Duration() >= ShowDuration) { reenableTimer = false; StopTimerAndUnregisterHandler(); Navigation.NavigateTo("/", true); } else if (!_showStarted) { ImminentClass = ""; await InvokeAsync( async() => await ShowIsStarting.InvokeAsync(_showStarted = true)); } } else { if (TimeRemaining <= TimeSpan.FromSeconds(30)) { // Starts in 30 seconds, show embedded Twitch stream ImminentClass = ""; await InvokeAsync( async() => await ShowIsStarting.InvokeAsync(_showStarted = true)); } else if (TimeRemaining <= TimeSpan.FromSeconds(90)) { // Starts in 90 seconds, start blinking ImminentClass = "blinking"; await InvokeAsync(() => StateHasChanged()); } else { // Show hasn't started, nor is it imminent, just keep ticking await InvokeAsync(() => StateHasChanged()); } } if (_timer != null) { _timer.Enabled = reenableTimer; } }