本帖最后由 失败且常态 于 2022-11-17 09:10 编辑 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
namespace WpfApplication2
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
///
public partial class MainWindow : Window
{
Thread threadAnimation = null;
public MainWindow()
{
InitializeComponent();
}
private void goAnimation()
{
int i = 1;
while (true)
{
this.Dispatcher.Invoke(() =>
{
image.Source = new BitmapImage(new Uri("/WpfApplication2;component/images/0" + i + ".png", UriKind.Relative));
Thread.Sleep(1000);
i = i + 1;
if (i > 4)
i = 1;
});
}
}
private void button_Click(object sender, RoutedEventArgs e)
{
threadAnimation.Start();
}
}
}
请问这是什么问题要怎么解决 |