public class Holder : IDisposable
{
public virtual void Dispose()
{
}
}
-----------------------------------
public class SplashHolder : Holder
{
private readonly Thread _thread;
public SplashHolder()
{
_thread = new Thread(_ShowWaitingForm);
_thread.Start();
}
public override void Dispose()
{
SplashForm.RequestCancel();
_thread.Join();
}
private void _ShowWaitingForm()
{
var f = new SplashForm {StartPosition = FormStartPosition.CenterScreen};
f.ShowDialog();
}
}
调用
using (new SplashHolder())
{
frm.show
Dispose(); //关闭等待画面
}