/// <summary>
/// 通用的单例制作器
/// </summary>
/// <typeparam name="T"></typeparam>
public class UniversalSingletonGeneator<T> where T : Form,new()
{
private static T t = null;
public static T CreateSingleton()
{
if (t == null || t.IsDisposed)
{
t = new T();
}
t.WindowState = FormWindowState.Normal;
t.Activate();
return t;
}
}
// 测试代码
var pFrm = UniversalSingletonGeneator<Form1>.CreateSingleton();
pFrm.Show();