2

I'd like to know if it is possible to switch from foreground app to background agent and vice-versa sharing some data from these two tasks?

More in deep I'd like to do an upload that starts from foreground (Fig. A) and when the user pushes back button the upload continues with background agent (Fig. B).

Image is here: http://imageshack.us/f/823/testter.jpg/

Heinrich Ulbricht
  • 10,064
  • 4
  • 54
  • 85
LXG
  • 1,957
  • 3
  • 22
  • 45

2 Answers2

2

You do realize that you can't update the tile constantly from a PeriodicTask right? The minimum refresh time is 30 minutes, unless you do push notifications (which I here, assume you won't, since it's a client-side operation).

And the tile itself doesn't make much sense. And I don't think using a task that can maximum run for 25 seconds makes a aweful lot of sense either for uploading a file.

So I guess we can conclude that it'll not be possible to do this. Instead , you should allow the application to run in the background, by setting the ApplicationIdleDetectionMode to Disabled

PhoneApplicationService.Current.ApplicationIdleDetectionMode = IdleDetecetionMode.Diabled"

Then the user can press the Home button, and the download will progress in the background.

Claus Jørgensen
  • 25,882
  • 9
  • 87
  • 150
  • The backgound task can inform the server side which will issue a push notification =) – Maxim V. Pavlov Nov 19 '11 at 22:16
  • There's many crazy ways to do it, if you *really* wanted to. I wouldn't recommend any of them :p – Claus Jørgensen Nov 19 '11 at 22:28
  • yes I read background file transfer but it's clearly in contrast with the "rules" of periodicTask... the problem is that background transfer isn't explained very well and there's no much examples :) – LXG Nov 23 '11 at 18:02
2

Background file transfer is what you need. It can upload (and download) files while the application is not running:

With Windows Phone OS 7.1, applications are able to queue up one or more file uploads or downloads over HTTP that will be executed in the background, even when the application is no longer running in the foreground. The APIs used for initiating file transfers should be used to query the status existing transfers and provide progress indicators for the end user.

Heinrich Ulbricht
  • 10,064
  • 4
  • 54
  • 85
  • I'm bit confused... I'd like upload an image on twitter from background agent so isn't possible? thanks – LXG Nov 23 '11 at 17:49