Is there a reason you're using SecureStorage.GetAsync("UserID").Result
instead of just await SecureStorage.GetAsync("UserID")
?
The former will block the UI thread & prevent messages from being pumped in the event loop.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
I have below code in my which allow the user Like ❤️ a Post just like Instagram likes for example
The problem is when I use Button Click or TapGesture with async like this:
async void LikeTapGestureRecognizer_Tapped(object sender, EventArgs e)
and if the user tried to like 3-4 post randomly in a short time then because if the async it will freeze for secodns everytime he Tap until the code is successfull.
How an I avoid this and let the code run at the background thread just like Instgarm, twitter and others..
Here is the code:
var client = new HttpClient();
client.BaseAddress = new Uri("https://www.domain.com/submit_like.php");
var content = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("post", "1"),
new KeyValuePair<string, string>("user", SecureStorage.GetAsync("UserID").Result ),
});
var response = await client.PostAsync("https://www.domain.com/submit_like.php", content);
Thanks,
Jassim
Is there a reason you're using SecureStorage.GetAsync("UserID").Result
instead of just await SecureStorage.GetAsync("UserID")
?
The former will block the UI thread & prevent messages from being pumped in the event loop.