设计模式 -- 我的记录

单例模式 -- winform
窗体
-------------------------------------------
private static SortManage instance;

public static SortManage GetInstance()
{
    //当窗体关闭后instance不为NULL,但已经Dispose,不能访问其内容,所以这种情况下也行重新构造
    if (instance == null || instance.IsDisposed)
    {
        instance = new SortManage();
    }
    return instance;
}


private SortManage()
{
    InitializeComponent();
}

父窗体
-------------------------------------------
SortManage sortManage 
= SortManage.GetInstance();
sortManage.TopMost 
= true;
sortManage.Show();

 

posted on 2010-02-27 20:41  snowleopard  阅读(84)  评论(0)    收藏  举报

导航