diff --git a/src/SQLite.cs b/src/SQLite.cs index ea5386fe4..734b2de5b 100644 --- a/src/SQLite.cs +++ b/src/SQLite.cs @@ -1483,42 +1483,48 @@ public int DeleteAll () return count; } - ~SQLiteConnection () - { - Dispose (false); - } - - public void Dispose () - { - Dispose (true); - GC.SuppressFinalize (this); - } - - protected virtual void Dispose (bool disposing) - { - Close (); - } - - public void Close () - { - if (_open && Handle != NullHandle) { - try { - if (_mappings != null) { - foreach (var sqlInsertCommand in _mappings.Values) { - sqlInsertCommand.Dispose(); - } - } - var r = SQLite3.Close (Handle); - if (r != SQLite3.Result.OK) { - string msg = SQLite3.GetErrmsg (Handle); - throw SQLiteException.New (r, msg); - } - } - finally { - Handle = NullHandle; - _open = false; - } - } + ~SQLiteConnection () + { + Dispose (false); + } + + public void Dispose () + { + Dispose(true); + GC.SuppressFinalize(this); + } + + public void Close() + { + Dispose(true); + } + + protected virtual void Dispose(bool disposing) + { + if (_open && Handle != NullHandle) { + try { + if (disposing) { + if (_mappings != null) { + foreach (var sqlInsertCommand in _mappings.Values){ + sqlInsertCommand.Dispose(); + } + } + + var r = SQLite3.Close(Handle); + if (r != SQLite3.Result.OK) + { + string msg = SQLite3.GetErrmsg(Handle); + throw SQLiteException.New(r, msg); + } + } else { + SQLite3.Close2(Handle); + } + } + finally { + Handle = NullHandle; + _open = false; + } + } } void OnTableChanged (TableMapping table, NotifyTableChangedAction action) @@ -2999,7 +3005,10 @@ public enum ConfigOption : int public static extern Result EnableLoadExtension (IntPtr db, int onoff); [DllImport("sqlite3", EntryPoint = "sqlite3_close", CallingConvention=CallingConvention.Cdecl)] - public static extern Result Close (IntPtr db); + public static extern Result Close (IntPtr db); + + [DllImport("sqlite3", EntryPoint = "sqlite3_close_v2", CallingConvention = CallingConvention.Cdecl)] + public static extern Result Close2(IntPtr db); [DllImport("sqlite3", EntryPoint = "sqlite3_initialize", CallingConvention=CallingConvention.Cdecl)] public static extern Result Initialize(); @@ -3159,6 +3168,11 @@ public static Result Close(Sqlite3DatabaseHandle db) return (Result)Sqlite3.sqlite3_close(db); } + public static Result Close2(Sqlite3DatabaseHandle db) + { + return (Result)Sqlite3.sqlite3_close_v2(db); + } + public static Result BusyTimeout(Sqlite3DatabaseHandle db, int milliseconds) { return (Result)Sqlite3.sqlite3_busy_timeout(db, milliseconds);