Multi-tasking work-around available in Windows Phone 7?

Windows Phone 7Doug Bolling, an engineer that specializes in Windows Embedded CE and Windows Mobile development that has written “Programming Windows Embedded CE”, now in its 4th edition, has looked at the Windows Phone 7 emulator and discovered a possible work-around to the lack of multi-tasking in the new OS.

He notes:

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.

While these threads can not access the user interface, if they can access outside resources it may allow for the completion of downloads while working in another application, a particularly useful feature.

Read more at Doug’s blog here.

Some links in the article may not be viewable as you are using an AdBlocker. Please add us to your whitelist to enable the website to function properly.

Related
Comments