From b705c56948ed11fdd3e02d622d94f3b2ce314c44 Mon Sep 17 00:00:00 2001 From: Chax Date: Tue, 23 May 2023 18:06:29 +0200 Subject: [PATCH] Move extraction into a thread to avoid UI Freezes. --- MainForm.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/MainForm.cs b/MainForm.cs index 1f39e444..bec67442 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -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);