Does the sqlite-net async API support dispose? Does the sqlite-net async API support dispose? sqlite sqlite

Does the sqlite-net async API support dispose?


I had the exact same problem in case where database was supposed to be sent via email for debugging/analyzing purposes. There was no way of doing that because connection is held.

You can go around this by modifying the sqlite-net implementation a bit.

On top of SQLiteAsync.cs add following partial class declaration.

namespace SQLite{    public partial class SQLiteAsyncConnection    {        public void ResetConnections()        {            SQLiteConnectionPool.Shared.Reset();        }    }}

and then change access modifier of above Reset method as public.

In your application code just call <YourSQLiteAsyncConnection>.ResetConnections(); before deleting the DB file.


Then again, when testing you could create your database in memory so you don't have to delete it at all. You can achieve this by setting DatabasePath as ":memory:".


On November 23rd 2015 they added a static method that does what Mikko Viitala suggested, So I just put the following in my dispose method.

SQLiteAsyncConnection.ResetPool();