设计模式 -- 我的记录
单例模式 -- winform
窗体
-------------------------------------------
private static SortManage instance;
public static SortManage GetInstance()
{
-------------------------------------------
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();
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) 收藏 举报

浙公网安备 33010602011771号