Skip to content

Commit 9c1b00b

Browse files
authored
Simplify thread marshal
1 parent d03a65b commit 9c1b00b

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

StabilityMatrix.Avalonia/Services/NotificationService.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,13 @@ public void Initialize(
4545
};
4646
}
4747

48-
public void Show(INotification notification)
49-
{
50-
// Must marshal to UI thread - WindowNotificationManager requires it
51-
if (Dispatcher.UIThread.CheckAccess())
48+
public void Show(INotification notification)
5249
{
53-
notificationManager?.Show(notification);
50+
// Must marshal to UI thread - WindowNotificationManager requires it
51+
Dispatcher.UIThread.Invoke(() => notificationManager?.Show(notification));
5452
}
55-
else
5653
{
57-
Dispatcher.UIThread.Post(() => notificationManager?.Show(notification));
54+
notificationManager?.Show(notification);
5855
}
5956
}
6057

0 commit comments

Comments
 (0)