简体   繁体   中英

background task timeline in windows phone 8.1

I am using the background task for a various features in the application. No where in the MSDN documentation, i see how long it runs.

For example in windows phone 8 sdk, periodic agents used to run for 25 seconds. is there a specific amount that the background task runs for ?

StorageFolder folder = KnownFolders.PicturesLibrary;
StorageFile TimeLogFile = await folder.CreateFileAsync("TimeLog.txt", CreationCollisionOption.OpenIfExists);

await Windows.Storage.FileIO.AppendTextAsync(TimeLogFile, "Start Logging " + DateTime.Now.ToString() + Environment.NewLine);
await Windows.Storage.FileIO.AppendTextAsync(TimeLogFile, "Beginning of Background Task " + DateTime.Now.ToString() + Environment.NewLine);

for (int i=0;i<100000;i++)
{
    await Windows.Storage.FileIO.AppendTextAsync(TimeLogFile, "During Background Task Execution " + DateTime.Now.ToString() + Environment.NewLine);
    Debug.WriteLine(i);
}
await Windows.Storage.FileIO.AppendTextAsync(TimeLogFile, "End Logging " + DateTime.Now.ToString() + Environment.NewLine);

Here's the info you're looking for: http://msdn.microsoft.com/en-us/library/windows/apps/xaml/Hh977056(v=win.10).aspx .

Basically, a background task can only use the CPU for 2 seconds each time it's started. It can however be active for a longer period, if it doesn't do CPU intensive work. If you await something slow that does not use the CPU too much, you can get to several minutes of execution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM