Correct way of handling click events and navigation

Hi.

I have an small doubt. Suppose you have a Click event of a button defined as async where you navigate to another page using await Navigation.PushAsync.

All is clear till now, but, as the click event is async (or if it's not async it doesn't waits the end of PushAsync) the user can tap really fast the button and then the code is executed twice and the new page is created twice.

What is the right way to handle this situation?

Actually y have a boolean which I set to true when the button is pressed and I set it to false on the OnAppearing of the page to aviod this double clicking, but it seems a bit ugly to me, is there another better approach to handle this?

Thanks in advance.

Best Answer

Answers

  • Oh god, so simple and it works perfect... sometimes one can't see the most obvious things...

    Thanks a lot Sean!

Sign In or Register to comment.