public Task RunInTransactionAsync(Action <SQLiteConnection> action) { if (action == null) { throw new ArgumentNullException("action"); } return(Task.Factory.StartNew(() => { SQLiteConnectionWithLock conn = GetConnection(); using (conn.Lock()) { conn.BeginTransaction(); try { action(conn); conn.Commit(); } catch (Exception) { conn.Rollback(); throw; } } }, CancellationToken.None, _taskCreationOptions, _taskScheduler ?? TaskScheduler.Default)); }
public Task RunInTransactionAsync(Action <SQLiteConnection> action) { if (action == null) { throw new ArgumentNullException("action"); } return(_taskFactory.StartNew(() => { SQLiteConnectionWithLock conn = GetConnection(); using (conn.Lock()) { conn.BeginTransaction(); try { action(conn); conn.Commit(); } catch (Exception) { conn.Rollback(); throw; } } })); }
public void DropDatabase() { if (conn != null) { conn.Rollback(); conn.Close(); conn.Dispose(); conn = null; } FileSystem.FileManager fm = new FileSystem.FileManager(); string path = GetDBPath(); fm.DeleteFile(path); }
private void Dispose(bool disposing) { if (isDisposed) { return; } if (disposing) { if (connection.IsInTransaction) { connection.Rollback(); } using (connection.Lock()) connection.Dispose(); } isDisposed = true; }