I'm developing a little app in Xamarin and I want to change the background color of a button just for 1 second when the user presses it. The code I'm trying to use is the following:
var auxColor = btnCancel.BackgroundColor; // saving the original color (btnCancel is the button name)
btnCancel.BackgroundColor = Color.Red; // changing the color to red
Task.Delay(1000).Wait(); // waiting 1 second
btnCancel.BackgroundColor = auxColor; // restoring the original color
But what I get is the following sequence:
1- Saving the original color
2- WAITING 1 SECOND
3 Changing the color to red
4 Immediately restoring the color
Does anybody know how to solve this problem?