修复bug和新增部分功能

This commit is contained in:
GG Z
2024-10-08 16:21:39 +08:00
parent 082b781808
commit b6647218be
44 changed files with 1709 additions and 1390 deletions

View File

@@ -6,7 +6,7 @@ namespace Sai.Toolkit.Core.Helpers;
public sealed record SingletonViewHelper<T>
where T : Window, new()
{
private static T instance;
private static T _instance;
private static readonly object Padlock = new();
private SingletonViewHelper() { }
@@ -15,21 +15,21 @@ public sealed record SingletonViewHelper<T>
{
isNewCreate = false;
//double-check locking
if (instance == null)
if (_instance == null)
{
isNewCreate = true;
lock (Padlock)
{
instance ??= new T();
instance.Closed += OnWindowClosed;
_instance ??= new T();
_instance.Closed += OnWindowClosed;
}
}
return instance;
return _instance;
}
private static void OnWindowClosed(object sender, EventArgs e)
{
instance = null;
_instance = null;
}
}