Sqlite-net: Multi-thread envrionment

Created on 5 Jan 2018  路  3Comments  路  Source: praeclarum/sqlite-net

I've just started using sqlite-net-pcl and have question related to multi-threading.
How safe is SQLiteConnection in multi-threading environment?

I've check https://www.sqlite.org/threadsafe.html documentation. From what I see the _engine_ itself has multiple modes I can rely in multi-threading environment (Multi-Thread: as user I just need to ensure to not share connection between threads (lock for single connection), Serialized: no need to care at all).
Is it any explicit way to ensure which mode I'm running?

SQLiteConnection has a lot of code around _raw_ engine. Also from what I see it keeps state (TableMappings), so is SQLiteConnection is thread safe itself?

Most helpful comment

Have you tried this?

 new SQLiteConnection(databasePath, SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create | SQLiteOpenFlags.FullMutex)

I had threading issues in the past until I started using those flags

All 3 comments

Have a look at the doc here. You can set these flags with SQLiteOpenFlags when creating a new SQLiteConnection.

Have you tried this?

 new SQLiteConnection(databasePath, SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create | SQLiteOpenFlags.FullMutex)

I had threading issues in the past until I started using those flags

@xleon that worked for me!
many thanks 馃憤

Was this page helpful?
0 / 5 - 0 ratings