Perform Background tasks in windows 7 phone - windows-phone-7

In Android we have Services to perform background tasks what can we use to do same in Windows Phone ?

Background Agent
Scheduled Tasks and background agents allow an application to execute code in the background, even when the application is not running in the foreground.

Related

Running settimeout in the background

Why doesn't settimeout/debounceTime work when the app is minimized? Events are still being triggered, but I was wondering if there is a way to make timers work while the app is backgrounded.
As soon user leaves your app, the system will stop it from running to reduce battery usage.
If you like your app to execute in background, you must use the appropriate options in the desired platform (Background Task / Fetch in iOS | Background services in Android).

Creating a Scheduled Task in windows phone

How can I repeat a particular task daily at a particular time in windows phone?I need to show a toast message to the user everyday at particular time.
Just use PeriodicTask class and configure it to run in background.
sample to check:
Windows Phone 8 Background Agent (Part 1: Periodic Task)

Permanent background task in WP7

Looking into developing an app for WP7 that requires continous monitoring GPS position. From what I can read from some searching there are certain limits to WP7 background tasks. Only scheduled for execution every 30 minutes, run for no more than 25 seconds, etc.
I would like to know how to bypass these limitations to permanently run a background task capable of monitoring GPS in real-time. (Think of Google Latitude for instance.)
You can't do that unless your app is actually running on the phone.
No background task can be permanent on WP7.

Windows Phone Launchers and choosers

I had a couple of queries about the windows phone 7 launcher tasks, Specifically a phonecalltask.
1) Does PhonecallTask Show() launch an application?
2) If so, What happens to the calling application? Does it go dormant or run on separate threads?
Tasks shelve the currently running application and run the ms supplied apps to make calls, play videos, send sms, email etc.
When you are in a task it will "Tombstone" your application so that you can save the data you need for when it recovers.
Showing a PhoneCallTask can be compared to receiving a phone call while in your application.

windows phone app running in the background

Is it possible to create an app the runs in the background? If so is there any samples out there for this?
In Windows Phone OS 7.1 you can actually use Background Agents now to perform tasks in the background.
from MSDN:
Scheduled Tasks and background agents allow an application to execute
code in the background, even when the application is not running in
the foreground. The different types of Scheduled Tasks are designed
for different types of background processing scenarios and therefore
have different behaviors and constraints.
You can use a PeriodicTask or ResourceIntensiveTasks. Read more about it in the MSDN article above.
And here's some sample code for you to integrate background agents into your existing app.
Sample Code: Background Agents in Mango
An application in the foreground can continue to run when the phone screen is locked(not background but...) by setting the PhoneApplicationService.ApplicationIdleDetectionMode property. By setting up your application to run when the phone screen is locked, a user is able to access the application quickly upon unlock. However, when your application runs under a locked screen, it could consume power outside of the user's control. For this reason, your application must minimize power usage when running under a locked screen
At the moment there is no way to create application that runs in background.
True multitasking for 3rd party Windows Phone 7 apps will come as an OS upgrade later this year. However, unless the app has to absolutely run in the background (like Pandora etc.), we as developers share some responsibility in making our apps feel at home with the rest of the OS.
Windows Phone OS offers app developers chances to save state of their applications to give the end users the feeling that it never stopped running; this is essentially the same as in other mobile platforms. As your app is being deactivated/closed, you have the option to "Tombstone" your state so that your users can come back to just where they left with BackStack navigation or future launches. Channel 9 had a nice set of demos & labs around tombstoning, found here.
Hope this helps!

Resources