Say, I created a custom button which includes some animation which is played when the button is clicked. The animation takes 500ms. During that time (until the animation is over), the button should not receive any inputs, and so should other items wait for it to end.
If I implement it like this:
public async void Clicked()
{
await Animate();
}
the UI thread won't be blocked and user will be able to press the button again during that time, or press Back
button, or do something else that I don't want him to be able to do.
If I implement it like this:
public void Clicked()
{
Animate();
}
the UI thread will be blocked until the Animate
returns.
My question is, is it a good idea to block UI thread in order to prevent user from double-clicking an item?
If no, what approach is considered good?