Background file transfer problems

I have this problem when using background file transfer in WP7. It works fine when my application is running, but as soon as I press the Windows button, it stops (and resumes when I activate the application again.) Exclude the destination of transferring the background file in the background, even if your application is deactivated? Should it be in a separate class (some background agent class, separate from the main project?) Really disappoints when I do everything that is said in this tutorial: http://msdn.microsoft.com/en-us/library /hh202959(v=vs.92).aspx .

Are there any β€œspecial” things that I need to do to make sure they work in the background, or some methods, maybe the ones that I created myself (to get the URL, etc. ) that cannot be accessed during the deactivation process? Can I not add to the queue when deactivating, maybe?

Thanks so much for your time :)

EDIT: A little debugging tells me that the file in the queue is actually loading. It ends, but it does not output the next until I activate the application. Can I use my own methods, variables, etc. Wherein? Perhaps I have an internal queue for, say, 20 elements. How can I then fill the download queue (max. 5) when it reaches zero?

EDIT2: in a Microsoft example, they say you can add to the queue later:

// Check to see if the maximum number of requests per app has been exceeded. if (BackgroundTransferService.Requests.Count() >= 5) { // Note: Instead of showing a message to the user, you could store the // requested file URI in isolated storage and add it to the queue later. MessageBox.Show("The maximum number of background file transfer requests for this application has been exceeded. "); return; } 

But he does not say whether we can do this in the background or not. Since we are talking about transferring background files, they should have mentioned this, otherwise we should assume that this can be done in the background, which seems to be wrong. But we cannot know this. Who can confirm this 100%?

+6
source share
1 answer

I also studied this, and it is impossible (based on my research) to fill the queue after max. 5 queued downloads completed. I thought about using a background agent, but BackgroundTransferRequest.Add is not available from background agents, which means that the only way to queue more downloads is when your application is running (see Unsupported APIs for Reference Agents for Windows Phone ).

The only thing I can think of is using a background agent to send a toast notification, letting the user know that the download is complete and that they need to start the application to queue the next five downloads. This is less than ideal.

+3
source

Source: https://habr.com/ru/post/901981/


All Articles