Introduction to Windows 8.1 Application development background tasks

Source: Internet
Author: User

Speaking of background tasks, this is one of the topics that is often mentioned when chatting with many Android developers, and the background task of Windows Mobile platform differs from the back-office service of Android, simply speaking in Windows RT Under the mobile platform, only some preset codes can be run when certain conditions are met. and Windows 8.1 and Windows Phone 8.0 are different for background tasks, and today I'm going to introduce you to the background tasks under the Windows 8.1 mobile platform and their operating conditions.

First of all, we introduce the application of Windows mobile platform to run the background of the scene is divided into many.

Today I will only introduce the following basic tasks, background tasks in response to system events (background task running conditions, servicingcomplete-apply update triggers), maintenance triggers, timer background tasks, which I one after the introduction to you.

Before that, I'll introduce the application configuration that uses the background.

To manually declare a supported background task type in the Package.appxmanifest file

Declaration in <Extensions> node

<application id= "Backgroundtasksample.app" executable= "BackgroundTaskSample.exe" Backgroundtasksample.app ">
<visualelements displayname= "backgroundtasksample" logo= images\squaretile-sdk.png "SmallLogo=" Images\ Smalltile-sdk.png "description=" backgroundtasksample "foregroundtext=" Dark "backgroundcolor=" #222222 ">
<lockscreen notification= "Badgeandtiletext" badgelogo= "Images\badgelogo.png"/>
<defaulttile showname= "Alllogos" widelogo= "Images\tile-sdk.png"/>
<splashscreen image= "Images\splash-sdk.png" backgroundcolor= "#FFFFFF"/>
</VisualElements>
<Extensions>
<!--todo:add elements here-->
</Extensions>
</Application>

For example:

<extension category= "Windows.backgroundtasks" entrypoint= "Tasks.backgroundtaskclass" >
         < backgroundtasks>
           <task type= "systemevent"/> <task "type=" pushnotification/>
         Backgroundtasks>
</Extension>

or directly in the graphical interface of the mouse tick note: here to manually enter a: Entry point This field is very important, this field and the back Backgroundtaskbuilder.taskentrypoint The parameters passed in when registering a task are consistent (in order to declare the permissions of the background agent and the namespace to run the agent logic)

For the Background Task Code Implementation section is simply divided into two parts:

Part I: Running the logical body itself (Business logic section) you need to create a background task class (specific steps to borrow the MSDN quote)

You can run code in the background by writing a class that implements the Ibackgroundtask interface. This code is run when a particular event is triggered using a trigger such as Systemtrigger or maintenancetrigger .

The following steps describe how to write a new class that implements the Ibackgroundtask interface. Before you start, create a new project for the background task in your solution. Adds a new empty class to the background task and imports the Windows.ApplicationModel.Background namespace.

Create a new project for the background task and add it to your solution. To do this, right-click your solution and select "Add"-> "New Project". Then select the Windows Runtime component project type, name the project, and click OK.

Apply a reference background task item from the Windows application store. First, right-click your Windows store application and select Properties, then go to Common Properties and click Add New Reference, select the check box next to the background task item, and then click OK in the two dialog boxes.

Create a new class that implements the Ibackgroundtask interface. The Run method is the input point that must be invoked when the specified event is triggered;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.