WPF多线程问题求教大神解答,在线等!

顾墨笙 顾墨笙 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
小白才开始用WPF,要做一个点击当前图片然后出现一个新窗体,因为新窗体加载数据有点多,想在新窗体没有出现之前做一个loading的效果。但是对多线程了解不多也不知道WPF中的这种多线程该怎么处理。求大神指教啊啊啊啊啊啊啊啊啊啊啊啊啊啊
private void gameImage1_MouseDown(object sender, MouseButtonEventArgs e)
{
try{
ShowLoading(true);
if (image.MakerId != null)
{
string[] str=new string[]{image.MakerId,image.Banner};
thread = new Thread(new ParameterizedThreadStart(gameLaunch));
thread.SetApartmentState(ApartmentState.STA);
thread.IsBackground = true;
thread.Start(str);
}

}catch{}
finally
{
ShowLoading(false);
}
}

private void gameLaunch(object obj)
{
string[] str = obj as string[];
int game = int.Parse(str[0]);
string brandName = str[1];
WindXLive wind = new WindXLive();
wind.Show();
System.Windows.Threading.Dispatcher.Run();
return;
}

private void ShowLoading(bool isShow)
{
if (isShow)
{
loading.Visibility = Visibility.Visible;
}
else
{
loading.Visibility = Visibility.Collapsed;
}
}


我现在是loading做了个用户控件,放在别的地方loading可以转动,但是放在这里可能是加载数据占用了线程,loading一直卡住不动
...全文
评论 20
收藏 已收藏
分享
返回顶部
顾墨笙
C# 111,129 成员 642,540 内容