/// <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();

相关文章:

  • 2022-01-25
  • 2022-12-23
  • 2021-11-17
  • 2021-06-09
  • 2021-12-12
  • 2022-12-23
  • 2021-06-06
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-02
  • 2021-05-30
  • 2022-12-23
  • 2020-10-18
  • 2021-12-30
相关资源
相似解决方案