Bugfix for update deadlock and increased version to 1.2.1.1

This commit is contained in:
Daniel Schick 2024-05-14 10:48:11 +02:00
parent c5df95625d
commit 97d4fa9faf

View File

@ -38,7 +38,8 @@ namespace BreCalClient
#region Fields #region Fields
private static Int32 _uiUpdateRunning = 0; //private static int _uiUpdateRunning = 0;
private static SemaphoreSlim uiLock = new SemaphoreSlim(1);
private Credentials? _credentials; private Credentials? _credentials;
@ -237,7 +238,7 @@ namespace BreCalClient
NewWithModel(null); NewWithModel(null);
} }
private void NewWithModel(ShipcallControlModel? model) private async void NewWithModel(ShipcallControlModel? model)
{ {
EditShipcallControl esc = new() EditShipcallControl esc = new()
{ {
@ -252,7 +253,9 @@ namespace BreCalClient
// create UI & save new dialog model // create UI & save new dialog model
if (esc.ShipcallModel.Shipcall != null) if (esc.ShipcallModel.Shipcall != null)
{ {
await uiLock.WaitAsync();
this.UpdateUI(); this.UpdateUI();
uiLock.Release();
esc.ShipcallModel.Shipcall?.Participants.Clear(); esc.ShipcallModel.Shipcall?.Participants.Clear();
foreach (ParticipantAssignment pa in esc.ShipcallModel.AssignedParticipants.Values) foreach (ParticipantAssignment pa in esc.ShipcallModel.AssignedParticipants.Values)
@ -346,10 +349,12 @@ namespace BreCalClient
this.FilterShipcalls(); this.FilterShipcalls();
} }
private void SearchFilterControl_SearchFilterChanged() private async void SearchFilterControl_SearchFilterChanged()
{ {
this.FilterShipcalls(); this.FilterShipcalls();
await uiLock.WaitAsync();
this.UpdateUI(); this.UpdateUI();
uiLock.Release();
} }
private void checkboxShowCancelledCalls_Checked(object sender, RoutedEventArgs e) private void checkboxShowCancelledCalls_Checked(object sender, RoutedEventArgs e)
@ -358,11 +363,13 @@ namespace BreCalClient
this.SearchFilterControl_SearchFilterChanged(); this.SearchFilterControl_SearchFilterChanged();
} }
private void comboBoxSortOrder_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) private async void comboBoxSortOrder_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{ {
_sortOrder = (Extensions.SortOrder) this.comboBoxSortOrder.SelectedIndex; _sortOrder = (Extensions.SortOrder) this.comboBoxSortOrder.SelectedIndex;
this.FilterShipcalls(); this.FilterShipcalls();
await uiLock.WaitAsync();
this.UpdateUI(); this.UpdateUI();
uiLock.Release();
} }
private void buttonHistory_Click(object sender, RoutedEventArgs e) private void buttonHistory_Click(object sender, RoutedEventArgs e)
@ -502,7 +509,9 @@ namespace BreCalClient
} }
this.FilterShipcalls(); this.FilterShipcalls();
await uiLock.WaitAsync();
this.UpdateUI(); this.UpdateUI();
uiLock.Release();
} }
try try
@ -765,7 +774,7 @@ namespace BreCalClient
this.Dispatcher.Invoke(new Action(() => this.Dispatcher.Invoke(new Action(() =>
{ {
if (Interlocked.CompareExchange(ref _uiUpdateRunning, 1, 0) == 1) return; //if (Interlocked.CompareExchange(ref _uiUpdateRunning, 1, 0) == 1) return;
try try
{ {
@ -785,7 +794,7 @@ namespace BreCalClient
} }
finally finally
{ {
_uiUpdateRunning = 0; // _uiUpdateRunning = 0;
} }
Mouse.OverrideCursor = null; Mouse.OverrideCursor = null;