oysteinkrog / SQLite.Net-PCL

Simple, powerful, cross-platform SQLite client and ORM - Updated version with PCL support
MIT License
353 stars 162 forks source link

Deadlock when trying to insert data asynchronously #322

Open Apidcloud opened 8 years ago

Apidcloud commented 8 years ago

Good afternoon,

Using Task.WhenAll for creating tables asynchronously (CreateTableAsync) works well, but doing the same thing for Inserting data doesn't (InsertAsync). Short example: var task1 = _connection.InsertAsync(data1); var task2 = _connection.InsertAsync(data2); await Task.WhenAll(task1, task2);

Doing the above deadlocks the app. I have also tried to use CancellationToken, but it doesn't work either.

I have noticed that if I wait for the result of the first insert (e.g., using ContinueWith), it works, so it's definitely an issue with concurrency.

Any ideas on how to achieve this?

Sincerely, Luís Fernandes