Doug 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.
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.