Reputation: 3
I have on click image and in that method i have this two pictures to set source for them:
image4.Source = (ImageSource)new ImageSourceConverter().ConvertFromString("Cards/" + player12.First() + ".png");
and
image5.Source = (ImageSource)new ImageSourceConverter().ConvertFromString("Cards/" + comp1.First() + ".png");
i have timer to wait but they show at the same time when execution of the method will be done. I want to reload grid after first image4.Source and then stop for two secounds with timer and then show image5.source. Thanks
Upvotes: 0
Views: 360
Reputation: 8126
Create a class for delayed execution:
public class OneShowDispatcherTimer
{
public static void FireAfter(TimeSpan inverval, Action callback)
{
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
DispatcherTimer Timer = new DispatcherTimer()
{
Interval = interval
};
Timer.Tick += (s, e) =>
{
Timer.Stop();
callback();
};
Timer.Start();
});
}
}
And use in that manner:
OneShowDispatcherTimer.FireAfter(TimeSpan.FromSeconds(2), () =>
{
image4.Source = ...
OneShowDispatcherTimer.FireAfter(TimeSpan.FromSeconds(2), () =>
{
image5.Source = ...
});
});
Upvotes: 1