I want to get all images from a storage folder in background task. Firstly registered a background task in app_entering background method. I am also able to debug Run method,but none of the await methods are working-
public void Run(IBackgroundTaskInstance taskInstance)
{
var differal = taskInstance.GetDeferral();
UpdateUI();
differal.Complete();
}
public async void UpdateUI()
{
StorageFolder folder = await KnownFolders.PicturesLibrary.GetFolderAsync("Wall_e_photos")//here execution stops and backgroundtaskhost exits.
var files = await GetFilesAsync();
foreach (StorageFile file in files)
{
if (file.Name.Contains("wall_e"))
{
}
}
}
Struggling from long time..Initially background tasks was not working,after it started working..now storage folder issue (backgroundtask exits when getting the folder).
Also for a note I followed this link- http://www.codeguru.com/win_mobile/win_store_apps/setting-wallpapers-in-a-windows-8-store-app-with-vb.htm
There they have used dispatcher,If I use var dispatcher=MyDispatcher = GetForCurrentThread().Dispatcher,then It gives null reference exception
IF I use Windows.ApplicationModel.Core.CoreApplication.MainView ,then it gives could not create a new view exception..
Please help me...