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 a289b014a3
commit 5bf5a2c8fa
4 changed files with 23 additions and 13 deletions

View File

@ -1 +1 @@
1.2.1.0 1.2.1.1

View File

@ -8,8 +8,8 @@
<SignAssembly>True</SignAssembly> <SignAssembly>True</SignAssembly>
<StartupObject>BreCalClient.App</StartupObject> <StartupObject>BreCalClient.App</StartupObject>
<AssemblyOriginatorKeyFile>..\..\misc\brecal.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>..\..\misc\brecal.snk</AssemblyOriginatorKeyFile>
<AssemblyVersion>1.2.1.0</AssemblyVersion> <AssemblyVersion>1.2.1.1</AssemblyVersion>
<FileVersion>1.2.1.0</FileVersion> <FileVersion>1.2.1.1</FileVersion>
<Title>Bremen calling client</Title> <Title>Bremen calling client</Title>
<Description>A Windows WPF client for the Bremen calling API.</Description> <Description>A Windows WPF client for the Bremen calling API.</Description>
<ApplicationIcon>containership.ico</ApplicationIcon> <ApplicationIcon>containership.ico</ApplicationIcon>

View File

@ -38,7 +38,8 @@ namespace BreCalClient
#region Fields #region Fields
private static int _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,15 +509,18 @@ namespace BreCalClient
} }
this.FilterShipcalls(); this.FilterShipcalls();
this.UpdateUI(); await uiLock.WaitAsync();
this.UpdateUI();
uiLock.Release();
} }
try try
{ {
double interval = (double) SHIPCALL_UPDATE_INTERVAL_SECONDS / PROGRESS_STEPS; double interval = (double) SHIPCALL_UPDATE_INTERVAL_SECONDS / PROGRESS_STEPS;
if (Interlocked.CompareExchange(ref _uiUpdateRunning, 1, 0) == 1) // do not restart progress unless UI update has completed
await Task.Delay(TimeSpan.FromSeconds(interval)); //if (Interlocked.CompareExchange(ref _uiUpdateRunning, 1, 0) == 1) // do not restart progress unless UI update has completed
// await Task.Delay(TimeSpan.FromSeconds(interval));
System.Diagnostics.Trace.WriteLine("restarting refresh countdown"); System.Diagnostics.Trace.WriteLine("restarting refresh countdown");
for (int i = 0; i < PROGRESS_STEPS; i++) for (int i = 0; i < PROGRESS_STEPS; i++)
@ -770,7 +780,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
{ {
@ -790,7 +800,7 @@ namespace BreCalClient
} }
finally finally
{ {
_uiUpdateRunning = 0; // _uiUpdateRunning = 0;
} }
Mouse.OverrideCursor = null; Mouse.OverrideCursor = null;

View File

@ -5,7 +5,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<ApplicationRevision>10</ApplicationRevision> <ApplicationRevision>10</ApplicationRevision>
<ApplicationVersion>1.2.1.0</ApplicationVersion> <ApplicationVersion>1.2.1.1</ApplicationVersion>
<BootstrapperEnabled>False</BootstrapperEnabled> <BootstrapperEnabled>False</BootstrapperEnabled>
<Configuration>Release</Configuration> <Configuration>Release</Configuration>
<CreateWebPageOnPublish>True</CreateWebPageOnPublish> <CreateWebPageOnPublish>True</CreateWebPageOnPublish>