Ejemplo n.º 1
0
 public void Dispose()
 {
     insert?.Dispose();
     @select?.Dispose();
     if (connection != null)
     {
         vacuumer.Remove(connection);
         Sqlite.ClearPool(connection);
         connection.Dispose();
     }
 }
Ejemplo n.º 2
0
        private void OpenConnection(FileInfo storeFile,
                                    out IDbConnection newConnection)
        {
            lock (globalLock)
            {
                newConnection = Sqlite.GetDatabaseConnection(storeFile);
                try
                {
                    using (var ver = newConnection.CreateCommand())
                    {
                        ver.CommandText = "PRAGMA user_version";
                        var currentVersion = (uint)(long)ver.ExecuteScalar();
                        if (!currentVersion.Equals(SCHEMA))
                        {
                            throw new IndexOutOfRangeException("SCHEMA");
                        }
                    }
                }
                catch (Exception ex)
                {
                    NoticeFormat(
                        "Recreating database, schema update. ({0})",
                        ex.Message
                        );
                    Sqlite.ClearPool(newConnection);
                    newConnection.Close();
                    newConnection.Dispose();
                    newConnection = null;
                    for (var i = 0; i < 10; ++i)
                    {
                        try
                        {
                            GC.Collect();
                            storeFile.Delete();
                            break;
                        }
                        catch (IOException)
                        {
                            Thread.Sleep(100);
                        }
                    }

                    newConnection = Sqlite.GetDatabaseConnection(storeFile);
                }

                using (var pragma = connection.CreateCommand())
                {
                    pragma.CommandText = "PRAGMA journal_size_limt = 33554432";
                    pragma.ExecuteNonQuery();
                }
            }
        }
Ejemplo n.º 3
0
 public void Dispose()
 {
     if (insert != null)
     {
         insert.Dispose();
     }
     if (select != null)
     {
         select.Dispose();
     }
     if (connection != null)
     {
         vacuumer.Remove(connection);
         Sqlite.ClearPool(connection);
         connection.Dispose();
     }
 }