I have to read from two folders where are thousands of picture and past them in a folder based in some condition (filering the extension)
private async Task FillFotoActiveWeb(IEnumerable<string> foto, string destination)
{
await Task.Run(() =>
{
foreach (var item in foto)
{
fotoProcessed++;
UpdateUI(fotoProcessed);
if (item.EndsWith("Big.jpg"))
continue;
var extension = "1Small.jpg";
var startIndex = (item.LastIndexOf("\\") + 1);
var articolo = item.Substring(startIndex).Replace("1Small.jpg", "");
if (Exist(articolo))
{
if (!IsNotActive(articolo))
{
fotoCopiate++;
File.Copy(item, destination + articolo + extension);
}
}
}
});
}
if i call this method two times in a button click
await FillFotoActiveWeb(fotoWeb, destinationPath);
await FillFotoActiveWeb(fotoStampa, destinationPath);
i see the destination folder is filled by first call and the second call start only when the first end
the question is how can i run symoultaneously this methods?