I'm working with a 3rd-party library that provides access to a database. In the database connection object, there is an event called Updated
, which fires whenever the database is modified.
I'm running into a snag when my delegate wants to read from the database. It looks like the connection has a ReaderWriterLock
protecting the database. During the ExecuteNonQuery
call, the writer lock is taken, but not released before the event fires. So, I'm deadlocked in my delegate if I want to read.
I started writing a separate thread that would take the event from the database connection and pass it along to the registered delegates, but that felt like a sloppy solution. Am I missing an easy way to handle this problem?
What's really bugging me is that I don't always hit the deadlock case. However when I do hit it and look at the call stack, it reaches all the way back to the point where I issued the update.
By the way, the library I'm using is System.Data.SQLite.