I can't figure out how to call last part of this method:
private static async Task ForEachFileAsync(string path, string searchPattern, SearchOption searchOption, Func<string, Task> doAsync)
{
// Avoid blocking the caller for the initial enumerate call.
await Task.Yield();
foreach (string file in Directory.EnumerateFiles(path, searchPattern, searchOption))
{
await doAsync(file);
}
}
This is what i have managed to do so far:
private void Stats_Load(object sender, EventArgs e)
{
ForEachFileAsync(@"E:\Path", "*", SearchOption.TopDirectoryOnly, what to put here? );
}
I Did not need an explanation of how System.Func works!! I only needed to know how to make a method call using System.Func which WAS NOT found at "Can someone explain what the C# "Func<T,T>" does?".
Adriani6 answer was the best and most helpful. Thanks