StartWritingTransaction() public method

public StartWritingTransaction ( ) : Task
return Task
示例#1
0
 public void EmptyWritingTransaction()
 {
     using (IKeyValueDB db = new InMemoryKeyValueDB())
     {
         using (var tr = db.StartWritingTransaction().Result)
         {
             tr.Commit();
         }
     }
 }
示例#2
0
 public void TwoEmptyWriteTransactionsWithNestedWaiting()
 {
     using (IKeyValueDB db = new InMemoryKeyValueDB())
     {
         Task<IKeyValueDBTransaction> trOuter;
         using (var tr = db.StartWritingTransaction().Result)
         {
             trOuter = db.StartWritingTransaction();
             tr.Commit();
         }
         using (var tr = trOuter.Result)
         {
             tr.Commit();
         }
     }
 }
示例#3
0
 public void StartWritingTransactionWorks()
 {
     using (IKeyValueDB db = new InMemoryKeyValueDB())
     {
         var tr1 = db.StartWritingTransaction().Result;
         var tr2Task = db.StartWritingTransaction();
         var task = Task.Factory.StartNew(() =>
             {
                 var tr2 = tr2Task.Result;
                 Assert.True(tr2.FindExactKey(_key1));
                 tr2.CreateKey(_key2);
                 tr2.Commit();
                 tr2.Dispose();
             });
         tr1.CreateKey(_key1);
         tr1.Commit();
         tr1.Dispose();
         task.Wait(1000);
         using (var tr = db.StartTransaction())
         {
             Assert.True(tr.FindExactKey(_key1));
             Assert.True(tr.FindExactKey(_key2));
         }
     }
 }