private async Task EnumerateRemindersAsync( IReliableDictionary2 <string, byte[]> reminderDictionary, Dictionary <string, ReminderCompletedData> reminderCompletedDataDict, ActorReminderCollection reminderCollection, CancellationToken cancellationToken) { using (var tx = this.stateManager.CreateTransaction()) { var enumerable = await reminderDictionary.CreateEnumerableAsync(tx); var enumerator = enumerable.GetAsyncEnumerator(); while (await enumerator.MoveNextAsync(cancellationToken)) { var data = enumerator.Current.Value; if (data == null) { continue; } var reminderData = ActorReminderDataSerializer.Deserialize(data); var key = CreateStorageKey(reminderData.ActorId, reminderData.Name); ReminderCompletedData reminderCompletedData; reminderCompletedDataDict.TryGetValue(key, out reminderCompletedData); reminderCollection.Add( reminderData.ActorId, new ActorReminderState(reminderData, this.logicalTimeManager.CurrentLogicalTime, reminderCompletedData)); } } }
private async Task <IEnumerable <TKey> > RangeFilterHelper(ITransaction tx, Func <TFilter, bool> filter, CancellationToken token) { // Since filters uses exact matches, each key should appear exactly once in the index. var keys = new List <TKey>(); // Include all values that fall within the range [start, end] inclusively. var enumerable = await _index.CreateEnumerableAsync(tx, filter, EnumerationMode.Ordered).ConfigureAwait(false); // Enumerate the index. var enumerator = enumerable.GetAsyncEnumerator(); while (await enumerator.MoveNextAsync(token).ConfigureAwait(false)) { keys.AddRange(enumerator.Current.Value); } return(keys); }
Task <IAsyncEnumerable <KeyValuePair <TKey, TValue> > > IReliableDictionary <TKey, TValue> .CreateEnumerableAsync(ITransaction tx) { return(_dictionary.CreateEnumerableAsync(tx)); }