I want to change the image source cyclically in my program, it's the C# code:
private void Img_MouseLeave(object sender, MouseEventArgs e)
{
Image image = sender as Image;
int milliseconds = 500;
for(int i = 0; i < ImageUris.Count(); i++)
{
Thread.Sleep(milliseconds);
image.Source = new BitmapImage(new Uri(@ImageUris[i], UriKind.Absolute));
}
}
But the problem is when I run my program the window is freezed. There is no happen in the window. I think maybe it's affected by thread, but I can't find a way do it.