diff --git a/CreamInstaller/Forms/DebugForm.cs b/CreamInstaller/Forms/DebugForm.cs index b21feb0..c8ba989 100644 --- a/CreamInstaller/Forms/DebugForm.cs +++ b/CreamInstaller/Forms/DebugForm.cs @@ -9,6 +9,7 @@ namespace CreamInstaller.Forms; internal sealed partial class DebugForm : CustomForm { private static DebugForm current; + private static readonly object currentLock = new(); private Form attachedForm; @@ -22,9 +23,14 @@ internal sealed partial class DebugForm : CustomForm { get { - if (current is not null && (current.Disposing || current.IsDisposed)) - current = null; - return current ??= new(); + lock (currentLock) + { + if (current is null || current.Disposing || current.IsDisposed) + { + current = new DebugForm(); + } + return current; + } } } diff --git a/CreamInstaller/Forms/SelectForm.cs b/CreamInstaller/Forms/SelectForm.cs index be71646..9ad5f87 100644 --- a/CreamInstaller/Forms/SelectForm.cs +++ b/CreamInstaller/Forms/SelectForm.cs @@ -25,6 +25,7 @@ internal sealed partial class SelectForm : CustomForm private const string HelpButtonListPrefix = "\n • "; private static SelectForm current; + private static readonly object currentLock = new(); private readonly ConcurrentDictionary remainingDLCs = new(); @@ -43,9 +44,14 @@ internal sealed partial class SelectForm : CustomForm { get { - if (current is not null && (current.Disposing || current.IsDisposed)) - current = null; - return current ??= new(); + lock (currentLock) + { + if (current is null || current.Disposing || current.IsDisposed) + { + current = new SelectForm(); + } + return current; + } } }