C#个人重构之单例模式

我的单例模式:

        [DllImport("user32")]
        public static extern int SetParent(int hWndChild, int hWndNewParent);


        #region 单例模式

        private static UIFormInquiryCollectionMoney fr = null;

        public UIFormInquiryCollectionMoney()
        {
            InitializeComponent();
            this.StartPosition = FormStartPosition.CenterScreen;
        }

        public static UIFormInquiryCollectionMoney GetInstance()
        {
            if (fr == null || fr.IsDisposed)
            {
                fr = new UIFormInquiryCollectionMoney();
                fr.MdiParent = ActiveForm;
                fr.Show();
            }
            SetParent((int)fr.Handle, (int)ActiveForm.Handle);
            return fr;
        }

        #endregion


你可能感兴趣的:(C#个人重构之单例模式)