Exemplo n.º 1
0
        public Task <IEnumerable <DirectoryEntry> > GetDirectoryEntries(DirectoryInfoEx directory, CancellationToken token)
        {
            var entries = directory.EnumerateDirectories("*", SearchOption.TopDirectoryOnly,
                                                         () => token.IsCancellationRequested);

            return(TaskCombinators.ThrottledAsync(entries, (entry, _) => Task.Run(() =>
            {
                using (entry)
                    return GetDirectoryEntry(entry, directory);
            }), token));
        }