public async Task Dispose_QueueNotFull_FlushedSuccessfully()
        {
            var batchExecutor = new BatchExecutor <int, string>(50, async items =>
            {
                await Task.Delay(10);
                var dictionary = items.ToDictionary(i => i, i => i.ToString());
                return(dictionary);
            }, TimeSpan.FromHours(1));
            var       tasks     = new List <Task <string> >();
            const int loopCount = 11;

            for (var i = 1; i <= loopCount; i++)
            {
                tasks.Add(batchExecutor.ExecAsync(i));
            }
            EnsureTaskStatus(loopCount, tasks, TaskStatus.WaitingForActivation, false);
            batchExecutor.Dispose();
            await Task.WhenAll(tasks).ConfigureAwait(false);

            EnsureTaskStatus(loopCount, tasks, TaskStatus.RanToCompletion, true);
        }
Beispiel #2
0
 public void Dispose()
 {
     _queue.Dispose();
 }