Wednesday, March 23, 2011

WP7 Devs- Ever get tired of dealing with the locked screen when you press F5?

There's an easy way to avoid ever having a deployment/debugging session aborted due to a locked screen. As you know, Windows Phone doesn't let us turn off the screensaver. If you are like me, you also don't want to disable & re-enter your password all the time either.

There's an easy fix for this problem though.

Just create a generic XNA game project called "StopLock" or whatever suits you, and this line to the Game constructor:

Guide.IsScreenSaverEnabled = false;

Build the project, deploy it, and run it before you start a coding session. When the game you are actually working on is started by the debugger, it will never give you any errors due to the device being locked because StopLock will have kept it open. When your program terminates, it will resume the StopLock app which will once again disable the screen saver.