Executing a foreach block simultaneously for all elements?

I have this foreach loop that changes the image source code for four images (in a Xamarin Forms application):

int i = 0;
            Device.StartTimer(TimeSpan.FromMilliseconds(50), () =>
            {
                i ++;
                foreach (var img in imgs)
                {
                    img.Source = $"radial{i}.png";
                }
                if (i == 5)
                    i = 0;
                return true;
            });

but the result is that the four images do not change at the same time, and the animation is not smooth. Here the grid is divided into four quarters, each quarter has its own kind of image:

enter image description here

When I use FromSeconds(1)instead FromMilliseconds(200), the animation becomes smoother

These are the images that I use, I rotate them when I want to draw a full circle:

enter image description here

+4
source share

Source: https://habr.com/ru/post/1690166/


All Articles