Retrieving records from Azure Storage account table using c# while developing cross platform app using xamarin giving error.
await tbl.ExecuteAsync(retrieveOperation);
This code gives exception (Time awaiting and Async error using storageexception) when ILogin() is executed separately i.e not through the Logmein().
When I run Logmein() with the code in current form, nothing happens i.e not exception error occurs.
When i use task.Wait(); exception/error occurs related to wait. I'll try to provide exception details.
My code is here
private void Logmein()
{
var task = Task.Run(async () => { await Ilogin(); });// Nothing happens by this code
//task.Wait(); It gives error/Exception.}
private static async Task Ilogin()
{
// Rest of the code is right (TESTED)
Microsoft.WindowsAzure.Storage.Table.CloudTable table = tableClient.GetTableReference("user");
Entry uname = new Entry();
Entry pword = new Entry();
Label linfo = new Label();
string userid = uname.Text.ToString();
string passcode = pword.Text.ToString();
Reg signuser = new Reg(userid);
TableOperation retrieveOperation = TableOperation.Retrieve<Reg>("regform", userid);
TableResult retrievedResult = await tbl.ExecuteAsync(retrieveOperation); //This AWAIT is making trouble
Reg loginuser = (Reg)retrievedResult.Result;
string u1 = loginuser.username.ToString();
string p1 = loginuser.password.ToString();
if (u1 == userid && p1 == passcode)
{
linfo.Text = "Login Successful";
//await Navigation.PushAsync(new MainPage());
}
else
{
linfo.Text = "Invalid Username or Password";
}
}
// here is my exception handling code
catch (Exception ex)
{
linfo.Text = "login Login Error" + ex.Message + ex.StackTrace + ex.HelpLink + ex.Source;
}
THANKS in advance.