Reloc.Extract.CompileEachFileAsync C# (CSharp) Method

CompileEachFileAsync() private static method

private static CompileEachFileAsync ( string path, string searchPattern, string SaveFolder, SearchOption searchOption, Func doAsync ) : System.Threading.Tasks.Task
path string
searchPattern string
SaveFolder string
searchOption SearchOption
doAsync Func
return System.Threading.Tasks.Task
        private static async Task CompileEachFileAsync(string path, string searchPattern, string SaveFolder, SearchOption searchOption, Func<string, string, Task> doAsync)
        {
            // Avoid blocking the caller for the initial enumerate call.
            await Task.Yield();

            var sw = Stopwatch.StartNew();

            // really need a simple exception swallowing filesystem walker, enumerations suck with exceptions !
            foreach (string file in Directory.EnumerateFiles(path, searchPattern, searchOption))
            {
                await doAsync?.Invoke(file, SaveFolder);
            }

            if (Verbose > 0)
                WriteLine($"processing time: {sw.Elapsed}");
        }