I am trying to call a aysnc method using latest xamrian in alpha using story board designer but i cant seem to call the method from a button click that has been declared by the desginer. CS
async public void Createuser ()
{
var user = new ParseUser ()
{
Username = txtUserName.Text,
Password = txtPassword.Text,
Email = txtEmail.Text
};
await user.SignUpAsync ();
}
the button which i wish to call the method from is this
partial void btnSave_TouchUpInside (UIButton sender)
{
Createuser();
}
But if we look at the following i the designer.cs file
[Action ("btnSave_TouchUpInside:")]
[GeneratedCode ("iOS Designer", "1.0")]
partial void btnSave_TouchUpInside (UIButton sender);
Based on your question, I assume that you can't just add the async modifier to the event handler as such?
async partial void btnSave_TouchUpInside (UIButton sender)
{
await Createuser();
}
I generally do my clicks inline using a lambda:
btnSave.TouchUpInside += async (sender, e) =>
{
await Createuser();
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With