I use recursive function to do something
public async void walk(StorageFolder folder)
{
IReadOnlyList<StorageFolder> subDirs = null;
subDirs = await folder.GetFoldersAsync();
foreach (var subDir in subDirs)
{
var dirPath = new Profile() { FolderPath = subDir.Path};
db.Insert(dirPath);
walk(subDir);
}
tbOut.Text = "Done!";
}
So, I want that tbOut.Text = "Done!"; will be done only after all iterations ends. At now it's happenning at the same time while iterations under process. If I run this function like that
walk(fd);
tbOut.Text = "Done!";
the result still the same. How to wait when this function will ends completely?
You don't await the completion of your sub-calls to your walk function.
So all you have to do is change it to await walk(subDir)
. However, since you can't await a void function you'll have to change it a bit to make it work.
To make your walk function awaitable change the return type to Task
like so:
public async Task walk(StorageFolder folder)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With