private void StartRecordingMatch() { if (CurrentRound != null) { ShowHUDmessage($"Recorded {CurrentRound.Name}"); } RecorderHandler?.StartRecordingMatch(); }
private void StopRecordingMatch() { if (CurrentMatch != null) { ShowHUDmessage($"Recorded Match{CurrentMatch.Name}"); } RecorderHandler?.StopRecordingMatch(); }
protected override async Task ExecuteAsync(CancellationToken token) { if (!RecorderSettings.RecordingEnabled) { return; } #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed Console.WriteLine($"Started {nameof( MatchRecorderService.ExecuteAsync )}"); Task.Factory.StartNew(async() => { while (!token.IsCancellationRequested) { CheckMessages(); RecorderHandler?.Update(); if (DuckGameProcess == null || DuckGameProcess.HasExited) { break; } await Task.Delay(TimeSpan.FromMilliseconds(100), token); } //wait 5 seconds for stuff to completely be done CancellationTokenSource fiveSecondsSource = new CancellationTokenSource(); fiveSecondsSource.CancelAfter(TimeSpan.FromSeconds(5)); StopRecordingRound(); StopRecordingMatch(); while (RecorderHandler.IsRecording && !fiveSecondsSource.Token.IsCancellationRequested) { RecorderHandler?.Update(); await Task.Delay(TimeSpan.FromMilliseconds(100), fiveSecondsSource.Token); } //request the app host to close the process AppLifeTime.StopApplication(); }, token, TaskCreationOptions.LongRunning, TaskScheduler.Default); await Task.CompletedTask; #pragma warning restore CS4014 }
private void StartRecordingRound() { RecorderHandler?.StartRecordingRound(); }