none
Continue task execution in background

    问题

  • I want the background task to continue execution in my metro style app. But from the white paper, "the app uses all of its available CPU time, its background tasks are suspended until the app’s CPU quota is replenished at the next generation for CPU quota updates".How can this be done? Thanks a lot.
    2012年3月20日 6:57

答案

  • "If images are being loaded in a view and the trigger stimulate the app go in background, I want that images continue to load and when user makes the app active again, he can see all the loaded images. Can this be done? Thanks a lot."

    Of course, it can. Try to take the BT sample, and test it, it will help you to load the data at background: http://code.msdn.microsoft.com/windowsapps/Background-Task-Sample-9209ade9 

    "Will the white page be modified and the meaning of background task might change?" 

    I think, it will be modified. Before the final release, any thing can be changed.


    Bob Bao [MSFT]
    MSDN Community Support | Feedback to us

    • 已标记为答案 Genrge 2012年3月22日 1:19
    2012年3月21日 16:19
    版主

全部回复

  • I think you miss some thing on this description.

    It means the background task (BT) will use some CPU time, unless the all available CPU time has been used by App.

    Normally, App will not use all available CPU time.

    And please note, there are to modes for BT, one is host in the backgroundTaskHost.exe, another is host in the Metro App process. So you should read the section "Background taks and Metro style app lifecycle". To continue the BT, you could resume or launch the App again.


    Bob Bao [MSFT]
    MSDN Community Support | Feedback to us

    2012年3月20日 10:08
    版主
  • Bob Bao,Grateful to get the answer, you mean that the the so-called CPU time is just for triggers other than tasks,right?

    From the white paper, "Each app on the lock screen receives 2 seconds of CPU time every 15 minutes, which can be used by all of the background tasks of the app",

     Does it mean that ,the task can only run for just 2s per 15m, or means that the trigger might run any time but the quota  might run out when to many times of triggers?

    Thanks again for answering.

    2012年3月21日 3:36
  • That is why we only can set the TimerTrigger value to 15min at least.

    Well, yes, base on the white page, the BT can get 2 seconds per 15min at lock screen. And in this 2seconds, read the following description "Any unused CPU time in the 15min interval is lost and not accumulated by the App"


    Bob Bao [MSFT]
    MSDN Community Support | Feedback to us

    2012年3月21日 4:29
    版主
  • I can't quite catch up with you,this is a senario ,could you please tell me yes or no.

    If images are being loaded in a view and the trigger stimulate the app go in background, I want that images continue to load and when user makes the app active again, he can see all the loaded images. Can this be done? Thanks a lot.

    Another question:

    Will the white page be modified and the meaning of background task might change?

    2012年3月21日 5:58
  • "If images are being loaded in a view and the trigger stimulate the app go in background, I want that images continue to load and when user makes the app active again, he can see all the loaded images. Can this be done? Thanks a lot."

    Of course, it can. Try to take the BT sample, and test it, it will help you to load the data at background: http://code.msdn.microsoft.com/windowsapps/Background-Task-Sample-9209ade9 

    "Will the white page be modified and the meaning of background task might change?" 

    I think, it will be modified. Before the final release, any thing can be changed.


    Bob Bao [MSFT]
    MSDN Community Support | Feedback to us

    • 已标记为答案 Genrge 2012年3月22日 1:19
    2012年3月21日 16:19
    版主
  • Hi, Bob, you are a great problem solver, I used this sample to down load a large mount of files and it worked fine, Any how, this seems to disobey the white paper. As it says: "Background tasks should be used for small work items that have no interaction with the user and only provide limited service. Long running or expensive workloads will deplete the user's battery and are not appropriate for background tasks". Am I making something wrong?
    2012年3月22日 2:14
  • The white pager suggests to do not use BT to work for the large work. That is one design guideline, not a rule. But yes, please do not design the expensive work in the BT, it may be limited by the battery, and for BT, we cannot do the interaction with UI, so a simple task is better for our design.

    Bob Bao [MSFT]
    MSDN Community Support | Feedback to us


    2012年3月22日 3:45
    版主