From 63b23a7b22c9285fa8f58b2b206405050a911267 Mon Sep 17 00:00:00 2001 From: Sour Date: Thu, 5 Dec 2019 22:21:34 -0500 Subject: [PATCH] Recent games: Improve UI responsiveness when disk is slow --- UI/Controls/ctrlRecentGame.cs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/UI/Controls/ctrlRecentGame.cs b/UI/Controls/ctrlRecentGame.cs index e222e2c..af9d713 100644 --- a/UI/Controls/ctrlRecentGame.cs +++ b/UI/Controls/ctrlRecentGame.cs @@ -44,19 +44,19 @@ namespace Mesen.GUI.Controls lblGameName.Text = Path.GetFileNameWithoutExtension(_recentGame.RomName); lblSaveDate.Text = _recentGame.Timestamp.ToString(); - try { - ZipArchive zip = new ZipArchive(new MemoryStream(File.ReadAllBytes(_recentGame.FileName))); - ZipArchiveEntry entry = zip.GetEntry("Screenshot.png"); - if(entry != null) { - using(Stream stream = entry.Open()) { - picPreviousState.Image = Image.FromStream(stream); + Task.Run(() => { + Image img = null; + try { + ZipArchive zip = new ZipArchive(new MemoryStream(File.ReadAllBytes(_recentGame.FileName))); + ZipArchiveEntry entry = zip.GetEntry("Screenshot.png"); + if(entry != null) { + using(Stream stream = entry.Open()) { + img = Image.FromStream(stream); + } } - } else { - picPreviousState.Image = null; - } - } catch { - picPreviousState.Image = null; - } + } catch { } + picPreviousState.Image = img; + }); lblGameName.Visible = true; lblSaveDate.Visible = true;