> ## Content Index
> Fetch the complete content index at: https://developerinsider.co/llms.txt
> Use this file to discover other available public pages before exploring further.

# Prevent the screen from locking on UWP
- URL: https://developerinsider.co/prevent-the-screen-from-locking-on-uwp/
- Published: 2016-03-13T09:40:53.000Z
- Updated: 2018-03-29T17:00:49.000Z
- Author: Vineet Choudhary
- Tags: Windows

This post contains answer to the question, How to prevent the screen from locking on Windows Universal Platform.

#### Simple Answer

[DisplayRequest](https://msdn.microsoft.com/en-us/library/windows/apps/windows.system.display.displayrequest.aspx?ref=developerinsider.co) class

```
var displayRequest = new DisplayRequest();
displayRequest.RequestActive(); //to request keep display on
displayRequest.RequestRelease(); //to release request of keep display on

```

---

#### Detailed Answer

Using display requests to keep the display on consumes a lot of power. Use these guidelines for best app behavior when using display requests.

1. Use display requests only when required, that is, times when no user input is expected but the display should remain on. For example, during full screen presentations or when the user is reading an e-book.
2. Release each display request as soon as it is no longer required.
3. Release all display requests when the app is suspended. If the display is still required to remain on, the app can create a new display request when it is reactivated.

###### To Request keep display on

```
private void Activate_Click(object sender, RoutedEventArgs e) 
{ 
    if (g_DisplayRequest == null) 
	{ 
	    g_DisplayRequest = new DisplayRequest(); 
    }
    if (g_DisplayRequest != null) 
	{ 
        // This call activates a display-required request. If successful,  
        // the screen is guaranteed not to turn off automatically due to user inactivity. 
        g_DisplayRequest.RequestActive(); 
        drCount += 1; 
    } 
}

```

###### To release request of keep display on

```
private void Release_Click(object sender, RoutedEventArgs e) 
{ 
	// This call de-activates the display-required request. If successful, the screen 
    // might be turned off automatically due to a user inactivity, depending on the 
    // power policy settings of the system. The requestRelease method throws an exception  
    // if it is called before a successful requestActive call on this object. 
	if (g_DisplayRequest != null) 
	{
		g_DisplayRequest.RequestRelease(); 
		drCount -= 1; 
	}
} 

```