Multitasking on Windows Phone and multitasking on PC are totally different things. When it comes to multitasking on PC, developers/end-users have luxury of humungous amount of processing power and memory. Where as on mobile device, there are restrictions. Firstly, Windows Phone 7 doesn’t support multitasking. Which means third-party applications [i.e. applications developed by you and I] will not run in background. If end-user doesn’t see any app UI on his device, then that application is not running. Period. The only applications which may run in background were developed by Microsoft, which are kind of ‘first party’ applications e.g. Zune media player, built-in Alarm and Reminders application. Which means, as of now, developers can’t write full blown media-players, location based services, alarm or reminder applications. Because they will be of no use if they are not running in background.
Having said that, Microsoft has introduced Multitasking functionality in coming release of Windows Phone, codenamed “Mango”. There is a complete namespace and few more new classes, which will support executing code [or let’s call it task] in the background. Note: Don’t confuse the term task with tasks in Microsoft.Phone.Tasks or Microsoft.Phone.TaskModel. Tasks in Microsoft.Phone.Task namespace will not take part in multitasking. There is separate namespace Microsoft.Phone.Scheduler which has classes allowing to build multitasking apps.
Broadly speaking, multitasking in Windows Phone is possible using classes given in Microsoft.Phone.Scheduler and those classes enable developers with functionalities like:
- Scheduled Notifications:
- Alarm : Used to create alarms.
- Reminders : Used to create reminders.
- Scheduled Tasks
- Periodic Tasks : Used to create tasks with short life, which will execute after some defined interval and which will not be resource intensive. e.g. updating user location or caching small amount of data
- Resource Intensive Tasks : Used to perform tasks running for long duration and consume lot of resources.
- Background Transfer Service: Used to create applications, which can transfer data in the background. Consider, creating a download manager kind of application using this service.
- Background Audio : In WP7, when media player application was created, if user moves to another application, the media player will stop playing that song. However in Mango, using this functionality, third-party media players will work like a charm. Along with it, IE9 on Mango has built in support for HTML5 with tag. Which will run media files in background inside browser. Amazing.
In next few posts, I’ll explain how you can do multitasking with this namespace. But before that, one quick question. How can you quickly navigate from one app to another which are taking part in multitasking? Simple, just press and hold back button for near about >2 seconds and it will bring a UI showing all the apps running in background and then you can switch the apps.
Mayur Tendulkar | www.mayurtendulkar.com