diff --git a/SafeExamBrowser.Client/App.cs b/SafeExamBrowser.Client/App.cs index d80d295e..c9bc4387 100644 --- a/SafeExamBrowser.Client/App.cs +++ b/SafeExamBrowser.Client/App.cs @@ -83,7 +83,7 @@ namespace SafeExamBrowser.Client base.Shutdown(); } - Dispatcher.BeginInvoke(new Action(shutdown)); + Dispatcher.InvokeAsync(shutdown); } } } diff --git a/SafeExamBrowser.UserInterface.Desktop/BrowserWindow.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/BrowserWindow.xaml.cs index 3206d5dd..e8d3d826 100644 --- a/SafeExamBrowser.UserInterface.Desktop/BrowserWindow.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/BrowserWindow.xaml.cs @@ -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) diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/ApplicationButton.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/ApplicationButton.xaml.cs index 0b000c6a..994113b6 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/ApplicationButton.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/ApplicationButton.xaml.cs @@ -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); - })); + }); } } } diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/ApplicationInstanceButton.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/ApplicationInstanceButton.xaml.cs index 265adf14..fda54826 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/ApplicationInstanceButton.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/ApplicationInstanceButton.xaml.cs @@ -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) diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/PowerSupplyControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/PowerSupplyControl.xaml.cs index 47741929..8d21ad91 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/PowerSupplyControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/PowerSupplyControl.xaml.cs @@ -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) diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/WirelessNetworkControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/WirelessNetworkControl.xaml.cs index 0b704aed..035425a2 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/WirelessNetworkControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/WirelessNetworkControl.xaml.cs @@ -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 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()