Skip to content

Commit aaabfbd

Browse files
committed
SteamWishlistDiscountNotifier: Fix crash during shutdown by safely dispatching TextBlock updates only when the app is running
1 parent 4a04b75 commit aaabfbd

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

source/Generic/SteamWishlistDiscountNotifier/Presentation/SteamWishlistViewerView.xaml.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,26 @@ private void TimerElapsedHandler(object sender, ElapsedEventArgs e)
4545

4646
private void UpdateTextBlocksText()
4747
{
48-
_dispatcher.Invoke(() =>
48+
try
4949
{
50-
try
50+
if (_dispatcher.HasShutdownStarted || _dispatcher.HasShutdownFinished)
51+
{
52+
return;
53+
}
54+
55+
_dispatcher.Invoke(() =>
5156
{
5257
foreach (var textBlock in _textBlocksToUpdate)
5358
{
5459
var binding = textBlock.GetBindingExpression(TextBlock.TextProperty);
5560
binding?.UpdateTarget();
5661
}
57-
}
58-
catch
59-
{
62+
});
63+
}
64+
catch
65+
{
6066

61-
}
62-
});
67+
}
6368
}
6469

6570
private void SteamWishlistViewerView_Unloaded(object sender, RoutedEventArgs e)

0 commit comments

Comments
 (0)