WinForm单例模式启动主窗体

static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(MainForm.Instance);
        }
    }



public partial class MainForm : Form
{

        static MainForm _form;
        public static MainForm Instance
        {
            get
            {
                if (null == _form)
                    _form = new MainForm();
                return _form;
            }
        }
}
posted @ 2012-04-21 22:10  跟着阿笨一起玩.NET  阅读(559)  评论(0编辑  收藏  举报