Good evening,
Can someone tell me why the code below does not respect Wait, in debug the output order is
-
1. init save
2. End Save 3. New header ID: 1
instead of:
-
1. init save
2. New header ID: 1
3. End Save
public async Task Save(Ticket header, TicketLines newLines)
{
Debug.WriteLine("init save");
await dbConnection.RunInTransactionAsync(new Action<SQLite.Net.SQLiteConnection>(tran =>
{
dbConnection.InsertAsync(header).ContinueWith((t) =>
{
Debug.WriteLine("New header ID: {0}", header.Id);
foreach (var item in newLines)
{
item.DocumentId = header.Id;
}
dbConnection.InsertAllAsync(newLines);
});
//tran.Commit();
}));
Debug.WriteLine("End Save");
}
I want to call the Save method and in the end I command refresh the screen, what happens as it does not respect the Await I have to refresh the screen and still not insert the data