So I made a simple Windows Phone 8 app that uploads a text file to the user's SkyDrive account. My code works fine while my app is running in the foreground, but when I attempt to upload a text file when my app is closing , it doesn't seem to work.
I'm using the Live Connect SDK v5.3 for WP8. SDK link: http://msdn.microsoft.com/en-us/library/live/hh826550.aspx
I'm using this piece of code to do the background upload when my app closes (when the user hits "back button" on their phone:
protected override void OnBackKeyPress(CancelEventArgs e)
{
SaveSkyDriveData();
base.OnBackKeyPress(e);
}
public async Task SaveSkyDriveData()
{
var res = await client.BackgroundUploadAsync("me/skydrive", new Uri("/shared/transfers/MyData.txt", UriKind.RelativeOrAbsolute), OverwriteOption.Overwrite);
}
Any ideas why this code doesn't work when the app is closing? I've read through the SDK that says this should work even after the app has been dismissed. Here's the SDK link for uploading files in the background: http://msdn.microsoft.com/en-us/library/live/hh826531.aspx#uploading_files
Thanks!