By default, a Windows Phone 7 application is tombstoned when the phone is locked in order to preserve the device’s battery. This happens when the user explicitly locks the screen by pressing the power button, or when the phone is automatically locked by the operating system. The PhoneApplicationService class exposes two properties that can be used to alter this behavior: UserIdleDetectionMode and ApplicationIdleDetectionMode. (The content of this post based on pre-release information from the Windows Phone developer tools that are subject to change.) UserIdleDetectionMode is set by default to IdleDetectionMode.Enabled, which allows the system to automatically lock the phone when the user is considered idle. When UserIdleDetectionMode is set to IdleDetectionMode.Disabled, the system will always consider the user to be active, which in effect prevents the phone from being automatically locked while the application is in foreground. An application can enable UserIdleDetectionMode after it has been disabled. This means that an application is free to disable user idle detection in certain situations, and leave it enabled in others. ApplicationIdleDetectionMode is also set by default to IdleDetectionMode.Enabled, which allows the system to deactivate the application once the phone is locked. Once set to IdleDetectionMode.Disabled, the system will not deactivate the application when the phone is locked, which allows the application to keep running under a locked screen. Unlike with UserIdleDetectionMode, though, ApplicationIdleDetectionMode cannot be re-enabled after it has been disabled. Once application idle detection has been disabled, the application will keep running when the phone is locked until it is deactivated or closed; application idle detection will be enabled (its default state) the next time the application is launched or activated. In addition, the Application Certification Requirements document (PDF) states that an application running under a locked screen must first ask the user for permission to do so and that the user must be able to configure this functionality from the application’s UI.