diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index a2b861c..1b6781c 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -287,6 +287,7 @@ public sealed partial class MainWindow : Window await _databaseActivityGate.WaitAsync(requestCancellation.Token); databaseActivityEntered = true; + requestCancellation.Token.ThrowIfCancellationRequested(); // Close the race where playout starts after this request is published // but before its market query begins. @@ -317,7 +318,26 @@ public sealed partial class MainWindow : Window } catch (OperationCanceledException) when (requestCancellation.IsCancellationRequested) { - // A newer navigation request or app shutdown superseded this response. + PostPlayoutPriorityMarketDataCancellationIfCurrent( + requestId, + view, + requestCancellation); + } + catch (DatabaseOperationException) when (requestCancellation.IsCancellationRequested) + { + // Some providers surface a provider exception instead of cancellation after + // a command has already taken priority. Never publish that stale failure. + PostPlayoutPriorityMarketDataCancellationIfCurrent( + requestId, + view, + requestCancellation); + } + catch (Exception) when (requestCancellation.IsCancellationRequested) + { + PostPlayoutPriorityMarketDataCancellationIfCurrent( + requestId, + view, + requestCancellation); } catch (DatabaseOperationException exception) { @@ -346,6 +366,26 @@ public sealed partial class MainWindow : Window } } + private void PostPlayoutPriorityMarketDataCancellationIfCurrent( + string requestId, + MarketDataView view, + CancellationTokenSource requestCancellation) + { + if (_lifetimeCancellation.IsCancellationRequested || + !ReferenceEquals( + Volatile.Read(ref _marketDataCancellation), + requestCancellation)) + { + // App shutdown or a newer navigation request superseded this response. + return; + } + + PostMarketDataError( + requestId, + view, + "송출 명령과 자동 갱신을 우선 처리하기 위해 조회를 취소했습니다. 다시 조회하세요."); + } + private void PostMarketDataError(string requestId, MarketDataView view, string message) { PostMessage("market-data-error", new