我在我的程序中使用了How do I get an animated gif to work in WPF?。Gif动画XAML C#已暂停
最初在XAML,我设置Visibility="Hidden"
和
使用animateImage.Visibility = Visibility.Visible;
,当我想要的图像显示。
显示图像后,我运行一个进程。但是,只要过程开始,动画就会暂停。 我想知道它为什么这样做?
我想创建一个新线程并在线程中运行GIF,并在进程完成时关闭线程。
编辑
代码,我运行的过程。我想在GPUpdate期间播放动画。
ExecProc("gpupdate", "/force");
private static bool ExecProc(string file, string arg)
{
bool flag = true;
try
{
//Create a new process info structure.
ProcessStartInfo pInfo = new ProcessStartInfo();
pInfo.FileName = file;
pInfo.CreateNoWindow = true;
pInfo.Arguments = arg;
pInfo.WindowStyle = ProcessWindowStyle.Hidden;
Process ps = new Process();
ps.StartInfo = pInfo;
ps.Start();
//Wait for the process to end.
ps.WaitForExit();
}
catch (Exception e)
{
writeLog("Error: " + e + " running " + file + " " + arg);
flag = false;
}
return flag;
}
您需要发表更多代码。您的流程很可能会阻止UI线程并阻止GIF播放,但您没有提供足够的详细信息来说明问题。 – WasGoodDone
@WasGoodDone所有的代码都是问题中的链接。我所做的只是在程序中隐藏或显示属性。除上述内容外,还有其他哪些代码?谢谢 – Imsa
你说“我运行一个进程。”这个过程的逻辑与你遇到的问题有关,因此将该代码作为问题的一部分会很有帮助。 http://stackoverflow.com/help/how-to-ask – WasGoodDone