Пример #1
0
 public Task <int> InsertOrIgnoreAsync(object item)
 {
     return(Task.Factory.StartNew(() =>
     {
         SQLiteConnectionWithLock conn = GetConnection();
         using (conn.Lock())
         {
             return conn.InsertOrIgnore(item);
         }
     }));
 }
Пример #2
0
        public static void RunInLock(this SQLiteConnectionWithLock connection, Action action)
        {
            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }

            using (connection.Lock())
            {
                //var savepoint = this.SaveTransactionPoint();
                try
                {
                    action();

                    //this.Release(savepoint);
                }
                catch (Exception)
                {
                    //this.RollbackTo(savepoint);
                    throw;
                }
            }
        }