Windows Phone 7 Apps Can Still Work in the Background

Advertisement

It’s been a bit confusing about what kind of multi-tasking scenarios are really going to be possible with Windows Phone 7. Some say it won’t be able to multi-task at all, while sometimes you can get the emulator to multitask. Doug Boling has a good blog post detailing how exactly Windows Phone 7’s multi-threaded multi-tasking operating system may work.



The Windows Phone team made waves when the platform was introduced by indicating that, at least initially, Window Phone would not multitask 3rd party applications. The answer sounded pretty absolute. The actual implementation isn’t.

This isn’t the place for a treatise on multithreaded managed applications. But briefly, very briefly, Windows Phone applications can be multithreaded. The main thread of the application calls the appropriate methods to create the main application form and is the “user interface thread”. Other threads created by the application can’t directly interact with the user interface. These threads are called “worker threads” or “background threads”.

When an application is sent to the background, the foreground thread is suspended. However, any worker threads currently running in the suspended application continue to run. These worker threads can call base class library methods such as querying the file system, reading and writing files, and such even while the application is “suspended”.

When a worker thread tries to invoke a method on the foreground thread, that request is queued but not executed. When the application is resumed, the queued calls are invoked.

Of course, “suspended” applications live on borrowed time. If the system needs the memory used by the application it will be terminated. At that point, the Application_Exit event should (but sometimes doesn’t) fire.

Advertisement
What's your reaction?
Love It
0%
Like It
0%
Want It
0%
Had It
0%
Hated It
0%
About The Author
Adam Z. Lein
Adam has had interests in combining technology with art since his first use of a Koala pad on an Apple computer. He currently has a day job as a graphic designer, photographer, systems administrator and web developer at a small design firm in Westchester, NY. His love of technology extends to software development companies who have often implemented his ideas for usability and feature enhancements. Mobile computing has become a necessity for Adam since his first Uniden UniPro PC100 in 1998. He has been reviewing and writing about smartphones for Pocketnow.com since they first appeared on the market in 2002.Read more about Adam Lein!