SEBWIN-226: Replaced all usages of Dispatcher.BeginInvoke with Dispatcher.InvokeAsync.

This commit is contained in:
dbuechel 2019-01-23 14:18:44 +01:00
parent 1fd6d4b99d
commit 44ac991c2c
6 changed files with 20 additions and 22 deletions

View file

@ -83,7 +83,7 @@ namespace SafeExamBrowser.Client
base.Shutdown();
}
Dispatcher.BeginInvoke(new Action(shutdown));
Dispatcher.InvokeAsync(shutdown);
}
}
}

View file

@ -98,7 +98,7 @@ namespace SafeExamBrowser.UserInterface.Desktop
public void UpdateIcon(IIconResource icon)
{
Dispatcher.BeginInvoke(new Action(() => Icon = new BitmapImage(icon.Uri)));
Dispatcher.InvokeAsync(() => Icon = new BitmapImage(icon.Uri));
}
public void UpdateLoadingState(bool isLoading)

View file

@ -89,11 +89,11 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls
private void Instance_OnTerminated(InstanceIdentifier id, ApplicationInstanceButton instanceButton)
{
Dispatcher.BeginInvoke(new Action(() =>
Dispatcher.InvokeAsync(() =>
{
instances.Remove(instances.FirstOrDefault(i => i.Id == id));
InstanceStackPanel.Children.Remove(instanceButton);
}));
});
}
}
}

View file

@ -6,7 +6,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
using System;
using System.Windows;
using System.Windows.Controls;
using SafeExamBrowser.Contracts.Configuration;
@ -44,7 +43,7 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls
private void Instance_IconChanged(IIconResource icon)
{
Dispatcher.BeginInvoke(new Action(() => Icon.Content = IconResourceLoader.Load(icon)));
Dispatcher.InvokeAsync(() => Icon.Content = IconResourceLoader.Load(icon));
}
private void Instance_NameChanged(string name)

View file

@ -6,7 +6,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
@ -33,7 +32,7 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls
public void SetBatteryCharge(double charge, BatteryChargeStatus status)
{
Dispatcher.BeginInvoke(new Action(() =>
Dispatcher.InvokeAsync(() =>
{
var width = BATTERY_CHARGE_MAX_WIDTH * charge;
@ -44,27 +43,27 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls
BatteryCharge.Fill = status == BatteryChargeStatus.Low ? Brushes.Orange : BatteryCharge.Fill;
BatteryCharge.Fill = status == BatteryChargeStatus.Critical ? Brushes.Red : BatteryCharge.Fill;
Warning.Visibility = status == BatteryChargeStatus.Critical ? Visibility.Visible : Visibility.Collapsed;
}));
});
}
public void SetPowerGridConnection(bool connected)
{
Dispatcher.BeginInvoke(new Action(() => PowerPlug.Visibility = connected ? Visibility.Visible : Visibility.Collapsed));
Dispatcher.InvokeAsync(() => PowerPlug.Visibility = connected ? Visibility.Visible : Visibility.Collapsed);
}
public void SetTooltip(string text)
{
Dispatcher.BeginInvoke(new Action(() => Button.ToolTip = text));
Dispatcher.InvokeAsync(() => Button.ToolTip = text);
}
public void ShowCriticalBatteryWarning(string warning)
{
Dispatcher.BeginInvoke(new Action(() => ShowPopup(warning)));
Dispatcher.InvokeAsync(() => ShowPopup(warning));
}
public void ShowLowBatteryInfo(string info)
{
Dispatcher.BeginInvoke(new Action(() => ShowPopup(info)));
Dispatcher.InvokeAsync(() => ShowPopup(info));
}
private void ShowPopup(string text)

View file

@ -26,11 +26,11 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls
{
set
{
Dispatcher.BeginInvoke(new Action(() =>
Dispatcher.InvokeAsync(() =>
{
Button.IsEnabled = value;
NoAdapterIcon.Visibility = value ? Visibility.Collapsed : Visibility.Visible;
}));
});
}
}
@ -38,12 +38,12 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls
{
set
{
Dispatcher.Invoke(new Action(() =>
Dispatcher.Invoke(() =>
{
LoadingIcon.Visibility = value ? Visibility.Visible : Visibility.Collapsed;
SignalStrengthIcon.Visibility = value ? Visibility.Collapsed : Visibility.Visible;
NetworkStatusIcon.Visibility = value ? Visibility.Collapsed : Visibility.Visible;
}));
});
}
}
@ -51,13 +51,13 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls
{
set
{
Dispatcher.BeginInvoke(new Action(() =>
Dispatcher.InvokeAsync(() =>
{
var icon = value == WirelessNetworkStatus.Connected ? FontAwesomeIcon.Check : FontAwesomeIcon.Close;
var brush = value == WirelessNetworkStatus.Connected ? Brushes.Green : Brushes.Orange;
NetworkStatusIcon.Source = ImageAwesome.CreateImageSource(icon, brush);
}));
});
}
}
@ -76,12 +76,12 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls
public void SetTooltip(string text)
{
Dispatcher.BeginInvoke(new Action(() => Button.ToolTip = text));
Dispatcher.InvokeAsync(() => Button.ToolTip = text);
}
public void Update(IEnumerable<IWirelessNetwork> networks)
{
Dispatcher.BeginInvoke(new Action(() =>
Dispatcher.InvokeAsync(() =>
{
NetworksStackPanel.Children.Clear();
@ -106,7 +106,7 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls
NetworksStackPanel.Children.Add(button);
}
}));
});
}
private void InitializeWirelessNetworkControl()