private async Task RebuildGridAsyncInner() {
try {
await Task.Delay(50);
OnPropertyChanged(nameof(IsBusy));
ErrorMessage = null;
again:
var mode = Mode;
var candidates = await FindCandidates();
if (mode != Mode) goto again;
// I’ve seen that XKCD comic, but I still think goto is more
// suitable than a loop here
if (candidates == null) return;
NonfilteredList.ReplaceEverythingBy(candidates);
} catch (SyntaxErrorException e) {
ErrorMessage = string.Format(ToolsStrings.Common_SyntaxErrorFormat, e.Message);
NonfatalError.Notify(ToolsStrings.RaceGrid_CannotUpdate, e);
} catch (ScriptRuntimeException e) {
ErrorMessage = e.Message;
} catch (InformativeException e) when (e.SolutionCommentary == null) {
ErrorMessage = e.Message;
} catch (Exception e) {
ErrorMessage = e.Message;
NonfatalError.Notify(ToolsStrings.RaceGrid_CannotUpdate, e);
} finally {
_rebuildingTask = null;
OnPropertyChanged(nameof(IsBusy));
}
}