Skip to content

Commit

Permalink
Move extraction into a thread to avoid UI Freezes.
Browse files Browse the repository at this point in the history
  • Loading branch information
frxctura committed May 23, 2023
1 parent 60b9fe5 commit b705c56
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2589,8 +2589,22 @@ public async void downloadInstallGameButton_Click(object sender, EventArgs e)
{
try
{
ChangeTitle("Extracting " + gameName, false);
Zip.ExtractFile($"{Properties.Settings.Default.downloadDir}\\{gameNameHash}\\{gameNameHash}.7z.001", $"{Properties.Settings.Default.downloadDir}", PublicConfigFile.Password);
Thread extractionThread = new Thread(() =>
{
ChangeTitle("Extracting " + gameName, false);
Zip.ExtractFile($"{Properties.Settings.Default.downloadDir}\\{gameNameHash}\\{gameNameHash}.7z.001", $"{Properties.Settings.Default.downloadDir}", PublicConfigFile.Password);
Program.form.ChangeTitle("");
})
{
IsBackground = true
};
extractionThread.Start();

while (extractionThread.IsAlive)
{
await Task.Delay(100);
}

if (Directory.Exists($"{Properties.Settings.Default.downloadDir}\\{gameNameHash}"))
{
Directory.Delete($"{Properties.Settings.Default.downloadDir}\\{gameNameHash}", true);
Expand Down

0 comments on commit b705c56

Please sign in to comment.