diff --git a/MPF/UserControls/LogOutput.xaml.cs b/MPF/UserControls/LogOutput.xaml.cs
index 8f2fce4d..e95b7b27 100644
--- a/MPF/UserControls/LogOutput.xaml.cs
+++ b/MPF/UserControls/LogOutput.xaml.cs
@@ -282,19 +282,11 @@ namespace MPF.UserControls
/// Color to print text in
private void AppendToTextBox(string text, Brush color)
{
- if (Application.Current.Dispatcher.CheckAccess())
+ Dispatcher.Invoke(() =>
{
- Run run = new Run(text) { Foreground = color };
+ var run = new Run(text) { Foreground = color };
_paragraph.Inlines.Add(run);
- }
- else
- {
- Dispatcher.Invoke(() =>
- {
- Run run = new Run(text) { Foreground = color };
- _paragraph.Inlines.Add(run);
- });
- }
+ });
}
///
@@ -303,25 +295,14 @@ namespace MPF.UserControls
/// Text to append
private string GetLastLine()
{
- if (Application.Current.Dispatcher.CheckAccess())
+ return Dispatcher.Invoke(() =>
{
if (!_paragraph.Inlines.Any())
return null;
var last = _paragraph.Inlines.LastInline as Run;
return last.Text;
- }
- else
- {
- return Dispatcher.Invoke(() =>
- {
- if (!_paragraph.Inlines.Any())
- return null;
-
- var last = _paragraph.Inlines.LastInline as Run;
- return last.Text;
- });
- }
+ });
}
///
@@ -416,10 +397,10 @@ namespace MPF.UserControls
/// Text to check and update with
private void ProcessStringForProgressBar(string text, Matcher? matcher)
{
- if (Application.Current.Dispatcher.CheckAccess())
+ Dispatcher.Invoke(() =>
+ {
matcher?.Apply(ref text);
- else
- Dispatcher.Invoke(() => { matcher?.Apply(ref text); });
+ });
}
///
@@ -429,21 +410,12 @@ namespace MPF.UserControls
/// Color to print text in
private void ReplaceLastLine(string text, Brush color)
{
- if (Application.Current.Dispatcher.CheckAccess())
+ Dispatcher.Invoke(() =>
{
var last = _paragraph.Inlines.LastInline as Run;
last.Text = text;
last.Foreground = color;
- }
- else
- {
- Dispatcher.Invoke(() =>
- {
- var last = _paragraph.Inlines.LastInline as Run;
- last.Text = text;
- last.Foreground = color;
- });
- }
+ });
}
#endregion