Using a Mutex to Access Common Resources Safely

Your app’s task agent may be invoked even when your app is in the foreground. It is, therefore, important to ensure that simultaneous access to shared resources, such as files in isolated storage, is controlled and performed safely.

A System.Threading.Mutex can be employed to synchronize critical sections of code—code that accesses a common resource—within your primary app and your background agent. A Mutex is a synchronization primitive. It is similar to the Monitor class, but with a scope that allows you to achieve interprocess synchronization, enabling you to synchronize across your foreground app and your background agent.

Unlike Silverlight for the browser, a Mutex instance in Windows Phone ...

Get Windows® Phone 8 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.