Ok, so the problem here is one of Task.Run and the way it is handled by async delegates . Basically when you say:
Task.Run(async () => ...)
What it returns to you is not the usual jane Task that you expect from it. He returns this task wrapped in another task, that is, a task. Therefore, to get the job you are looking for (the one that retrieves the StorageFolder), you need to await external task. You can do this simply by changing by adding it to the tasks list:
tasks.Add(await task);
Now there is a second problem. You are doing a bunch of reading from the same folder, possibly at the same time. This may cause some AccessExceptions . It may also not be. I will just be careful about this.
I had problems reading / writing files in unit tests in WinRT. Fortunately, I use Mvvm (via Mvvm Light) and wrapped the local storage available inside Controller . This allowed me to write LocalStorageController only for unit testing, which allows me to execute all my IOs in the file system in memory (basically a simple Dictionary<string, byte[]> ). This makes it difficult to test complex file trees, but you can also use a different data structure (for example, the actual Tree ) to model your file system.
Anyway, I hope this helps. I apologize that it was so long after you asked about it. Happy coding!
source share