WPF多线程问题求教大神解答,在线等!
小白才开始用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一直卡住不动
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一直卡住不动
...全文
相关推荐
WPF和Silverlight的重要常见问题解答
以下是关于WPF和Silverlight的21个重要常见问题的详细解答。1. **什么是WPF?
解决WPF中空域问题(Airspace issuse)
若有任何疑问,开发者可以留言并期待进一步的解答,同时也要感谢所有支持者对我们网站的支持。
WPF高频面试题与解答,让你轻松找到理想工作
在本文中,我们将深入探讨WPF(Windows Presentation Foundation)中的几个关键概念,包括依赖属性、附加属性和样式,这些都是在WPF开发中面试时经常出现的主题,同时也是构建高效
WPF Unleashed code
**Questions or Problems.txt**:这可能是一个常见问题解答或用户反馈文档,提供了关于代码或书中内容的解答,帮助解决学习过程中遇到的难题。
wpf打开图片显示到界面
这涉及到了WPF UI设计、文件操作和图像处理的基础知识。希望这个详尽的解答能帮助你理解和实现所需的功能。


