Skip to content

Commit

Permalink
Merge pull request #811 from VladiStep/updaterRandomErrorFix
Browse files Browse the repository at this point in the history
Random NullReferenceException of "UpdateApp()" fix (attempt).
  • Loading branch information
Grossley authored Mar 28, 2022
2 parents b8b8a45 + 8a9578b commit 33b45bf
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion UndertaleModTool/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2390,6 +2390,7 @@ public async void UpdateApp(SettingsWindow window)
using (WebClient webClient = new())
{
bool end = false;
bool ended = false;
string downloaded = "0.00";

webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler((sender, e) =>
Expand All @@ -2402,7 +2403,14 @@ public async void UpdateApp(SettingsWindow window)
end = true;

HideProgressBar();
scriptDialog = null;
_ = Task.Run(() =>
{
// wait until progress bar updater loop is finished
while (!ended)
Thread.Sleep(100);

scriptDialog = null;
});

if (e.Error is not null)
{
Expand Down Expand Up @@ -2497,6 +2505,8 @@ public async void UpdateApp(SettingsWindow window)

Thread.Sleep(100);
}

ended = true;
});

webClient.DownloadFileAsync(new Uri(downloadUrl), Path.GetTempPath() + "UndertaleModTool\\Update.zip");
Expand Down

0 comments on commit 33b45bf

Please sign in to comment.