예제 #1
0
        static Task StartReader(IKeyValueDB lowDb, string id, int sleep, CancellationToken cancellationToken)
        {
            return(Task.Run(async() =>
            {
                while (true)
                {
                    var transaction = lowDb.StartReadOnlyTransaction();
                    transaction.FindFirstKey();
                    var keyValueCount = transaction.GetKeyValueCount();
                    for (long kv = 0; kv < keyValueCount; kv++)
                    {
                        transaction.GetKey();
                        transaction.GetValue();
                        transaction.FindNextKey();
                        await Task.Delay(sleep, cancellationToken);

                        if (cancellationToken.IsCancellationRequested)
                        {
                            return;
                        }
                    }

                    Console.Write($"{id} ");
                }
            }, cancellationToken));
        }
예제 #2
0
 public IObjectDBTransaction StartReadOnlyTransaction()
 {
     return(new ObjectDBTransaction(this, _keyValueDB.StartReadOnlyTransaction(), true));
 }
 public IKeyValueDBTransaction StartReadOnlyTransaction()
 {
     return(new KeyValueDBTransactionWithCount(_keyValueDB.StartReadOnlyTransaction()));
 }