Multitasking for Microsoft Windows Phone

Introduction

While Windows Phone platform brought a new and much improved mobile operating system from Microsoft, the first version did not have the platform maturity its rivals enjoyed at the moment. However with Windows Phone Mango, also called the 7.5 version of the Windows Phone operating system, Microsoft brought in about 500 changes from the 7.0 release, the primary being the multitasking, which brought with it parity with its rivals.

For performance optimization, Windows Phone runs only one process in the foreground (unlike our desktops which can run quite a few). To ensure that user experience is optimal, Windows Phone Mango now has the ability to run an application in the background (so display resources are only utilized for the process running in the foreground).

With Windows Phone 7.5, the support for multitasking has added new possibilities in what the Windows Phone user can now do. Let us take a look at what new scenarios are enabled as a result of multitasking.

Background Audio

You no longer are constrained to keeping your Music player application running while you desperately want to check your Facebook Wall or the latest YouTube trending video. An application developer can create an AudioPlayerAgent, which can run in the background rendering your favorite tunes while you check your email /Facebook posts.

Scheduled Tasks

multitasking in the Windows Phone platform enables scheduled tasks. This feature allows applications to run code in the background when the main application is not running. Check out the Background Agents article for more details on this.

Background File Transfers

You no longer have to wait for an active download in your application to move on to the next important thing on your phone. Windows Phone Mango allows applications to use the background transfer service to queue downloads, which can be performed when the application is not running in the foreground. At the time of writing this article, both uploading and downloading files in the background are supported.

The APIs reside in the Microsoft.Phone.BackgroundTransfer class.

Scheduled Notifications

This is akin to the alarm clock facility, however, this feature is meant for an application to set up reminders to launch itself. The reminders can be one-time or recurring. You can use the ScheduledNotification class to do this.

Faster Application Switching

With Windows Phone 7.0, any action that navigated a user away from the application would result in termination of the application. With Windows Phone 7.5, this behavior has changed for the better. Upon navigating away, an application is put into a dormant state. When the user navigates back to the application, it restores its state and hence it can resume instantly without any performance delays. This feature is on by default, so applications do not have to write even a single line of code to support this.

Tombstoning

While discussing the new possibilities unleashed by multitasking, we should not forget that primary drives, which enables this behavior. Due to the limited resources available on these mobile devices, the operating system will try to swap resources from an idle application and give them to an in-use application. While developers in general dislike this feature, they have to account for this Windows Phone operating system behavior in their application invocation scenarios and architect their application accordingly. An application can be tombstoned away and resurrected back. Tombstoning also follows a Deactivated event, although a deactivated application isn't guaranteed to be tombstoned.

An application enters the Deactivated/Tombstoned stage usually when the user presses the Start button, or the lock screen comes up, or a user clicks a popped-up toast of another application and navigates to it.

In all such cases, the application needs to handle the state transition accurately to allow the application user a pleasant experience.

Summary

In this article, we learned about the new features that are enabled on the Windows Phone platform by the introduction of multitasking in Mango.



About the Author

Vipul Vipul Patel

Vipul Patel is a Software Engineer currently working at Microsoft Corporation, working in the Office Communications Group and has worked in the .NET team earlier in the Base Class libraries and the Debugging and Profiling team. He can be reached at vipul_d_patel@hotmail.com

Related Articles

Comments

  • There are no comments yet. Be the first to comment!

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: December 11, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT Market pressures to move more quickly and develop innovative applications are forcing organizations to rethink how they develop and release applications. The combination of public clouds and physical back-end infrastructures are a means to get applications out faster. However, these hybrid solutions complicate DevOps adoption, with application delivery pipelines that span across complex hybrid cloud and non-cloud environments. Check out this …

  • On-demand Event Event Date: October 29, 2014 It's well understood how critical version control is for code. However, its importance to DevOps isn't always recognized. The 2014 DevOps Survey of Practice shows that one of the key predictors of DevOps success is putting all production environment artifacts into version control. In this webcast, Gene Kim discusses these survey findings and shares woeful tales of artifact management gone wrong! Gene also shares examples of how high-performing DevOps …

Most Popular Programming Stories

More for Developers

RSS Feeds