There's nothing in your code that lends itself to being
async
. If you want the items to appear one at a time, then you'll need to add a delay between adding them - for example:
public static async Task<bool> DisplayOriginalFiles(List<string> files)
{
TimeSpan delayTime = TimeSpan.FromSeconds(0.5);
foreach (string file in files)
{
string fileName = Path.GetFileName(file);
string filePath = Path.GetDirectoryName(file);
Gbl.rO.Add(new RenameObservable(fileName, "", "Orig Loaded", true, true, filePath, file));
await Task.Delay(delayTime);
}
return true;
}
NB: Your method of getting the file path is dangerously wrong. The file name could appear earlier in the path, which would result in you looking in the wrong folder. Eg:
C:\passwords.txt\Windows\System32\passwords.txt
would yield a path of
C:\\Windows\System32\
, which is just wrong.
Use the
Path.GetDirectoryName
to extract the path, rather than trying to roll your own.