WaitingFormHelper

using Lba_Ciac;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms; namespace Lbb.Cx.Ciac.Utility
{
public class WaitingFormHelper
{
private Loading waitingForm = null; private Action _method = null; private WaitingFormHelper(Action method, string message)
{
this._method = method;
this.waitingForm = new Loading();
this.waitingForm.Text = message;
this.waitingForm.StartPosition = FormStartPosition.CenterParent;
this.waitingForm.Shown += new EventHandler(this.waitingForm_Shown);
}
public static void ShowWaitingForm(Action method, string message)
{
WaitingFormHelper waitingFormHelper = new WaitingFormHelper(method, message);
waitingFormHelper.waitingForm.ShowDialog();
} private void waitingForm_Shown(object sender, EventArgs e)
{
try
{
this._method.BeginInvoke(new AsyncCallback(this.callBack), null);
}
catch (System.ObjectDisposedException)
{
return;//如果主界面已经退出了,那线程也退出好了。
}
} private void callBack(IAsyncResult ar)
{
if (this.waitingForm != null && !this.waitingForm.IsDisposed)
{
this.waitingForm.Invoke(new Action(delegate
{
this.waitingForm.Close();
}));
}
}
}
}

  

上一篇:android原生系统裁剪


下一篇:lsb_release查看当前系统的发行版信息