日期:2014-05-17 浏览次数:21038 次
//////////////////////////////////////////////////////////////
FrmLoading:只有构造函数:
public FrmLoading()
{
//防止多线程操作Lable时报错
Control.CheckForIllegalCrossThreadCalls = false;
InitializeComponent();
}
//////////////////////////////////////////////////////////////
FrmUser:
private FrmLoading _FrmLoading;
private Thread _ThreadLoading = null;
public string _LoadingMsg = string.Empty;
/// <summary>
/// 显示等待提示
/// </summary>
public void LoadingShow()
{
_ThreadLoading = new Thread(new System.Threading.ThreadStart(Loading));
_ThreadLoading.Start();
}
/// <summary>
/// 处理等待提示
/// </summary>
private void Loading()
{
if (string.IsNullOrEmpty(_LoadingMsg))
{
_LoadingMsg = "正在处理,请等待结果显示...";
}
_FrmLoading = new FrmLoading();
_FrmLoading.labelMsg.Text = _LoadingMsg;
_FrmLoading.ShowDialog();
}
/// <summary>
/// 关闭等待提示
/// </summary>
public void LoadingClose()
{
if (_FrmLoading != null)
{
_LoadingMsg = string.Empty;
_FrmLoading.Dispose();
if (_ThreadLoading != null)
{
_ThreadLoading.Abort();
_ThreadLoading = null;
}
}
}
//////////////////////////////////////////////////////////////
调用方式:
LoadingShow()
//执行操作...
LoadingClose()
//////////////////////////////////////////////////////////////