I have a database that is accessed by two threads. One thread writes to the database and regular intervals while the other thread performs read operations. Each thread has its own connection pointer, and I have synchronized access even further by using lock. In short:
lock (syncObject)
{
using (SQLiteConnection connection = new SQLiteConnection(ConnectionString))
{
...
}
}
SyncObject is shared by the two threads.
Based on this I think I have followed what should be done when using multiple thread access to the database. However, from time to time I get an SQLite exception telling me that its trying to write an readonly database. Im guessing that the writer thread is trying to write a database that is still opened by the reader thread. The question is how is this possible?