Floating FB popout byF5debug

101 How to on Windows Phone – How to #90 – How to Avoid Screen lock while debugging your Windows Phone Application


In this article we are going to see how to disable the screen locking feature while we debugging the application on the emulator or the device. When we develop our application and to test it on the emulator or the device on certain scenarios we need to disable the automatic screen lock to test the application feature. In real device we can avoid the automatic screen lock by changing the settings where as in the emulator to test it we need to manage in the code itself to make the lock screen disabled while debugging the application.   [more]

To debug the application from the Visual Studio IDE we need to keep the mode to debug as the release mode will not allow to debug the code to get the progress by selecting the debug option from the Debugger type. Let us see how to debug the application with making the screen lock disabled for debugging. Open Visual Studio 2012 IDE in administrator mode and create a new Windows Phone project with a valid project name as shown in the screen below.


Clicking on OK will create the project and the solution with the list of default files and folders that are required to run the application. It will take some time to create these files based on your system configuration, so once everything is ready we can see the Visual Studio IDE with the project as shown in the screen below.


To lock the screen while debugging from the emulator we need add the below code which basically checks if the debugger is enabled and makes the IdleDetectionmode to disabled which makes the lock screen to take action to lock the screen on the debugger mode as shown in the below code which we can write on the app load event.

C# Code:


if (System.Diagnostics.Debugger.IsAttached)
               PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;



Now run the application in the emulator and we can see the application loads into the emulator and lock screen will not function as we run the application in debugging mode.

About Author: Karthikeyan Anbarasan, Microsoft MVP (Most Valuable Professional) in ASP.NET/IIS Architecture. He is the Founder and Chief Editor of the www.f5debug.net website and has authored books on Windows Phone and Business Intelligence(SSIS). He is also a Passionate Speaker and a Blogger on Microsoft Technologies.

You can Join Me On: Facebook, Twitter, Google Plus, LinkedIn

Add comment

  Country flag

  • Comment
  • Preview

Recent Posts

Random Posts

Most Viewed

URL Shortner

Create your own short urls!!!

Site Counter

free counters


This is a personal weblog. The opinions expressed here represent my own and not those of my employer. For accuracy and official reference refer to MSDN/ TechNet. I have documented my personal experience on this blog.

Protected by Copyscape Web Plagiarism Finder

Site Meter