Singleton pattern

 public partial class SingleNotifyWithCloseDialog : BaseForm
    {
        private static volatile SingleNotifyWithCloseDialog _instance;

        private static object syncRoot = new object();

        public static SingleNotifyWithCloseDialog  Instance
        {
            get
            {
                if (_instance == null || _instance.IsDisposed)
                {
                    lock (syncRoot)
                    {
                        if (_instance == null || _instance.IsDisposed)
                        {
                            _instance = new SingleNotifyWithCloseDialog();
                        }
                    }
                }
                return _instance;
            }
        }
}

  

posted @ 2014-07-11 17:14  penney  阅读(77)  评论(0)    收藏  举报