title: How to wait for the database lock to clear in system.data.sqlite
body: <p>My application works in the following way: Each query opens a new connection to the database file with sqlite3, and after the query runs, it closes the connection with the close() method. </p>
  
  <p>The problem: Another thread created by my application needs to do an INSERT query, but while this is happening the "main" body of my application is performing some SELECTs and they seem to collide and since sqlite doesn't allow selects and updates at the same time, it cases problems. Namely, the application freezes for 30 seconds, after which the sqlite connection times out and I get:</p>
  
  <pre><code>A first chance exception of type 'System.Data.SQLite.SQLiteException' occurred in System.Data.SQLite.dll
  System.Data.SQLite.SQLiteException (0x80004005): database is locked
  </code></pre>
  
  <p>Is there some way to instruct a query to wait for the lock to clear before trying to proceed? Or perhaps some other way of solving the problem? </p>