WPF 线程开启等待动画

public static Dictionary<string, object> Dic = new Dictionary<string, object>();//定义一个字典类型的接受窗体信息


public static void AwaitAnimation(bool isStart = true)
{
if (isStart == true)
{
Thread t = new Thread(() =>
{
Pmtoload sw = new Pmtoload();
Dic["SplashWindow"] = sw;//储存
sw.ShowDialog();//不能用Show
});
t.SetApartmentState(ApartmentState.STA);
t.IsBackground = true;
t.Start();
return;
}
if (isStart == false)
{
if (HymlaserLoadedConfig.Dic.ContainsKey("SplashWindow"))
{
Pmtoload sw = Dic["SplashWindow"] as Pmtoload;
sw.Dispatcher.Invoke(() => sw.Close());//在sw的线程上关闭SplashWindow

}
return;
}
}

posted @ 2019-08-02 10:04  可乐_加冰  阅读(1092)  评论(1编辑  收藏  举报