avoid thread termination by catching exception thrown on failed times GET
This commit is contained in:
parent
5bf5a2c8fa
commit
dd61368233
@ -472,45 +472,56 @@ namespace BreCalClient
|
||||
}
|
||||
}
|
||||
|
||||
if (shipcalls != null)
|
||||
try
|
||||
{
|
||||
foreach (Shipcall shipcall in shipcalls)
|
||||
{
|
||||
// load times for each shipcall
|
||||
List<Times> currentTimes = await _timesApi.TimesGetAsync(shipcall.Id);
|
||||
|
||||
if(!_allShipcallsDict.ContainsKey(shipcall.Id))
|
||||
if (shipcalls != null)
|
||||
{
|
||||
foreach (Shipcall shipcall in shipcalls)
|
||||
{
|
||||
// add entry
|
||||
ShipcallControlModel scm = new()
|
||||
// load times for each shipcall
|
||||
List<Times> currentTimes = await _timesApi.TimesGetAsync(shipcall.Id);
|
||||
|
||||
if (!_allShipcallsDict.ContainsKey(shipcall.Id))
|
||||
{
|
||||
Shipcall = shipcall,
|
||||
Times = currentTimes
|
||||
};
|
||||
this.AddShipcall(scm);
|
||||
// add entry
|
||||
ShipcallControlModel scm = new()
|
||||
{
|
||||
Shipcall = shipcall,
|
||||
Times = currentTimes
|
||||
};
|
||||
this.AddShipcall(scm);
|
||||
}
|
||||
else
|
||||
{
|
||||
// update entry
|
||||
_allShipcallsDict[shipcall.Id].Shipcall = shipcall;
|
||||
_allShipcallsDict[shipcall.Id].Times = currentTimes;
|
||||
UpdateShipcall(_allShipcallsDict[shipcall.Id]);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
List<int> existingIds = new(this._allShipcallsDict.Keys);
|
||||
|
||||
foreach (int existingId in existingIds)
|
||||
{
|
||||
// update entry
|
||||
_allShipcallsDict[shipcall.Id].Shipcall = shipcall;
|
||||
_allShipcallsDict[shipcall.Id].Times = currentTimes;
|
||||
UpdateShipcall(_allShipcallsDict[shipcall.Id]);
|
||||
if (shipcalls.Find(s => s.Id == existingId) == null) // the model is no longer in the search result
|
||||
{
|
||||
this.RemoveShipcall(existingId);
|
||||
}
|
||||
}
|
||||
|
||||
this.FilterShipcalls();
|
||||
await uiLock.WaitAsync();
|
||||
this.UpdateUI();
|
||||
}
|
||||
|
||||
List<int> existingIds = new(this._allShipcallsDict.Keys);
|
||||
|
||||
foreach (int existingId in existingIds)
|
||||
{
|
||||
if (shipcalls.Find(s => s.Id == existingId) == null) // the model is no longer in the search result
|
||||
{
|
||||
this.RemoveShipcall(existingId);
|
||||
}
|
||||
}
|
||||
|
||||
this.FilterShipcalls();
|
||||
await uiLock.WaitAsync();
|
||||
this.UpdateUI();
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
_log.Error(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
uiLock.Release();
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user