I am working with the Magazine sample app for using DirectWrite from a XAML-based app. It has a FontLoader class, which has the LoadAsync method, which does something like this:
void FontLoader::LoadAsync()
{
// Locate the "fonts" sub-folder within the document folder
task<StorageFolder^> getFolder(m_location->GetFolderAsync("Fonts"));
getFolder.then([=](StorageFolder^ folder)
{
// Enumerate a list of .TTF files in the storage location
auto filters = ref new Platform::Collections::Vector<Platform::String^>();
filters->Append(".ttf");
auto queryOptions = ref new QueryOptions(CommonFileQuery::DefaultQuery, filters);
auto queryResult = folder->CreateFileQueryWithOptions(queryOptions);
return queryResult->GetFilesAsync();
}).then([=](IVectorView<StorageFile^>^ files)
{
// Here is some more async processing code.
});
}
How can I make a Sync version of this method and wait for the whole chain to finish? I basically want to wait until all the async tasks here (also the tasks inside the second continuation) are completed.
I tried to call getFolder.wait() at the end of the function, but that threw an exception.
Thanks.