I have the following in an async method
await MyDatabase.InsertA(a);
await MyDatabase.InsertB(b);
await MyDatabase.InsertC(c);
await MyDatabase.InsertD(d);
The insert methods look like this
async Task InsertA(a foo)
{
using (asyncLock.LockAsync())
{
var sqlcon = new SQLiteAsyncConnection(ConnectionString);
try
{
if (await sqlcon.ExecuteAsync("UPDATE a SET tid=?, id=?, type=?," +
"name=?,value=?,technote=? WHERE tid=?",
t.tid, t.id, t.type, t.name, t.value, t.technote, t.tid) == 0)
await sqlcon.InsertAsync(foo).ContinueWith((w) => Console.WriteLine("a inserted"));
}
catch (Exception ex)
{
Console.WriteLine("Error in InsertA - {0}:{1}", ex.Message, ex.InnerException);
}
}
}
(they all follow this sort of format)
the first two inserts both show that a and b have been inserted (this comes from the ContinueWith). However, the third insert is never hit (I have a breakpoint on it).
I've not used sqliteasync in anger before now, so it's possible that I'm deadlocking somewhere (though the LockAsync() should prevent that). Any help or advice here would be appreciated.
Aucun commentaire:
Enregistrer un commentaire