Skip to content

Commit 56a8d96

Browse files
committed
GSF.Core: Push enumeration processing tasks onto the processing thread instead of awaiting them
1 parent dd5ebcd commit 56a8d96

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

Source/Libraries/GSF.Core/IO/FileProcessor.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -361,12 +361,13 @@ async Task VisitFileAsync(FileInfo file)
361361
bool matchesFilter = m_fileProcessor.MatchesFilter(trackedPath);
362362

363363
// The file must be processed on the processing thread
364-
await processingThread.Join(FileProcessor.ProcessNormalPriority);
365-
366-
if (matchesFilter)
367-
m_fileProcessor.TouchAndProcess(trackedPath, lastWriteTime, false);
368-
else
369-
m_fileProcessor.TouchAndSkip(trackedPath, lastWriteTime);
364+
processingThread.Push(FileProcessor.ProcessNormalPriority, () =>
365+
{
366+
if (matchesFilter)
367+
m_fileProcessor.TouchAndProcess(trackedPath, lastWriteTime, false);
368+
else
369+
m_fileProcessor.TouchAndSkip(trackedPath, lastWriteTime);
370+
});
370371
}
371372

372373
async Task EnumerateSubdirectoriesAsync()
@@ -398,10 +399,6 @@ async Task EnumerateFilesAsync()
398399

399400
IEnumerable<Task> processTasks = files.Select(VisitFileAsync);
400401
await Task.WhenAll(processTasks).ConfigureAwait(false);
401-
402-
// The continuation of VisitFileAsync() will execute on the
403-
// processing thread so we need to join back to the appropriate thread
404-
await enumerationThread.Join();
405402
}
406403

407404
EventHandler<EventArgs<List<string>>> handler = (sender, args) =>

0 commit comments

Comments
 (0)