Detect when screen is locked UWP
问题 How can I detect if the screen is locked in UWP apps? When screen is locked, suspension of app occurs and I need to put some different code in case of locking screen. 回答1: You will find your answer here: https://developerinsider.co/prevent-the-screen-from-locking-on-uwp/ For those that are not looking for a link to another post that could, or could not, potentially be helpful here is the summary The code you would use is var displayRequest = new DisplayRequest(); displayRequest.RequestActive(