Windows 8 Background task

Source: Internet
Author: User
Background task example this example shows how to create and register background tasks using Windows to run background task APIs. A background task is a system or time event that can be restricted by one or more conditions. When a background task is triggered, it is associated Program Background of running and executing tasks. A background task can run an application even if the registered background task is paused. This example demonstrates the following: • Create and register background tasks using C # or JavaScript. • Create a background task that is triggered by a system event. • Add a condition to restrict the running of background tasks only when the condition is actually. • Report the background task progress and complete it to the foreground application. • Process and cancel background tasks. • Initialize the task process and background completion handler when starting the application. Private Void Onprogress (ibackgroundtaskregistration sender, backgroundtaskprogresseventargs E)
{
//
// Update the UI with progress reported by the background task.
//
Sampledispatcher. invokeasync (coredispatcherpriority. Normal,
(Task, argS) =>
{
VaR Taskregistration = task As Ibackgroundtaskregistration;
VaR Progressargs = args. Context As Backgroundtaskprogresseventargs;

If (Task! = Null ) & (ARGs! = Null ))
{
Switch (Taskregistration. Name)
{
Case Samplebackgroundtaskname:
Samplebackgroundtaskprogress. Text = " Progress: " + Progressargs. Progress + " % " ;
Break ;
Case Samplebackgroundtaskwithconditionname:
Samplebackgroundtaskwithconditionprogress. Text = " Progress: " + Progressargs. Progress + " % " ;
Break ;
Case Servicingcompletetaskname:
Servicingcompleteprogress. Text = " Progress: " + Progressargs. Progress + " % " ;
Break ;
Case Timetriggeredtaskname:
Timetriggeredbackgroundtaskprogress. Text = " Progress: " + Progressargs. Progress + " % " ;
Break ;
}
}
},
Sender,
E );

}

Complete example/files/risk/windows8/background task sample.rar

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.