fix timer handling

This commit is contained in:
beo3000 2025-11-26 18:23:51 +01:00
parent e55ce2d53a
commit 2e5892444d
3 changed files with 2008 additions and 62 deletions

View File

@ -189,11 +189,9 @@ namespace KoogleApp.Store.Game.ThrowPanel
await ShowBoardForSeconds(dispatcher); await ShowBoardForSeconds(dispatcher);
// save again - save the new state after the throw // save the new state after the throw
dispatcher.Dispatch(new TriggerNewThrowPanelStateChangedAction(true, dispatcher.Dispatch(new TriggerNewThrowPanelStateChangedAction(true,
gameSpecificProgress.AfterParticipantsState, gameSpecificProgress.GameModel)); // this will trigger ThrowPanelStateChangedAction with the new state (not current _throwPanelState.Value) gameSpecificProgress.AfterParticipantsState, gameSpecificProgress.GameModel)); // this will trigger ThrowPanelStateChangedAction with the new state (not current _throwPanelState.Value)
} }
private async Task ShowBoardForSeconds(IDispatcher dispatcher) private async Task ShowBoardForSeconds(IDispatcher dispatcher)

View File

@ -32,7 +32,12 @@ namespace KoogleApp.Store.Game.ThrowTimer
{ {
for (var i = 0; i < action.Seconds; i++) for (var i = 0; i < action.Seconds; i++)
{ {
await Task.Delay(1000, _timerCancellation.Token); var token = CancellationToken.None;
if (_timerCancellation != null)
{
token = _timerCancellation.Token;
}
await Task.Delay(1000, token);
dispatcher.Dispatch(new TickAction()); dispatcher.Dispatch(new TickAction());
} }
@ -48,12 +53,15 @@ namespace KoogleApp.Store.Game.ThrowTimer
[EffectMethod] [EffectMethod]
public async Task HandleStopTimer(StopTimerAction action, IDispatcher dispatcher) public async Task HandleStopTimer(StopTimerAction action, IDispatcher dispatcher)
{ {
logger.LogInformation("Timer wird gestoppt"); if (_timerCancellation is { IsCancellationRequested: false })
await _timerCancellation?.CancelAsync()!; {
_timerCancellation = null; logger.LogInformation("Timer wird gestoppt");
await _timerCancellation?.CancelAsync()!;
_timerCancellation = null;
await ReturnToThrowView(); await ReturnToThrowView();
}
} }
private async Task ReturnToThrowView() private async Task ReturnToThrowView()

File diff suppressed because it is too large Load Diff