Run manual refresh asynchronously to keep UI responsive
This commit is contained in:
@@ -67,6 +67,7 @@ namespace C4IT_CustomerPanel
|
|||||||
private DispatcherTimer _regularTimer;
|
private DispatcherTimer _regularTimer;
|
||||||
private DispatcherTimer _checkServerConnectionTimer;
|
private DispatcherTimer _checkServerConnectionTimer;
|
||||||
private bool _initialTimerInvocationDone = false;
|
private bool _initialTimerInvocationDone = false;
|
||||||
|
private bool _manualRefreshInProgress = false;
|
||||||
private TimeSpan _lastTicketInterval;
|
private TimeSpan _lastTicketInterval;
|
||||||
private TimeSpan _lastAdHocInterval;
|
private TimeSpan _lastAdHocInterval;
|
||||||
private TimeSpan _lastRegularInterval;
|
private TimeSpan _lastRegularInterval;
|
||||||
@@ -1461,11 +1462,45 @@ namespace C4IT_CustomerPanel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnRefreshClicked(object sender, MouseButtonEventArgs e)
|
private async Task TriggerManualRefreshAsync()
|
||||||
{
|
{
|
||||||
OnReloadTimerElapsed(sender, e);
|
if (_manualRefreshInProgress)
|
||||||
OnAdHocTimerElapsed(sender, e);
|
return;
|
||||||
OnRegularTimerElapsed(sender, e);
|
|
||||||
|
var CM = MethodBase.GetCurrentMethod();
|
||||||
|
LogMethodBegin(CM);
|
||||||
|
|
||||||
|
_manualRefreshInProgress = true;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
bool force = ((Keyboard.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt);
|
||||||
|
if (RefreshIcon != null)
|
||||||
|
RefreshIcon.IsEnabled = false;
|
||||||
|
|
||||||
|
await Task.WhenAll(
|
||||||
|
OnReloadTimerElapsedAsync(force),
|
||||||
|
OnAnnoncementTimerReloadAsync(announcementType.Adhoc),
|
||||||
|
OnAnnoncementTimerReloadAsync(announcementType.Regular));
|
||||||
|
|
||||||
|
SetAppearance(false);
|
||||||
|
}
|
||||||
|
catch (Exception E)
|
||||||
|
{
|
||||||
|
LogException(E);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (RefreshIcon != null)
|
||||||
|
RefreshIcon.IsEnabled = true;
|
||||||
|
_manualRefreshInProgress = false;
|
||||||
|
LogMethodEnd(CM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void OnRefreshClicked(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
|
await TriggerManualRefreshAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnCloseClicked(object sender, MouseButtonEventArgs e)
|
private void OnCloseClicked(object sender, MouseButtonEventArgs e)
|
||||||
@@ -1487,9 +1522,9 @@ namespace C4IT_CustomerPanel
|
|||||||
HideMainForm();
|
HideMainForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnRefreshButtonClick(object sender, RoutedEventArgs e)
|
private async void OnRefreshButtonClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
OnRefreshClicked(sender, null);
|
await TriggerManualRefreshAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnMinimizeButtonClick(object sender, RoutedEventArgs e)
|
private void OnMinimizeButtonClick(object sender, RoutedEventArgs e)
|
||||||
|
|||||||
Reference in New Issue
Block a user