DisplayRequest 클래스

정의

표시 요청을 나타냅니다.

public ref class DisplayRequest sealed
/// [Windows.Foundation.Metadata.Activatable(65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.None)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.STA)]
class DisplayRequest final
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.None)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.STA)]
/// [Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
class DisplayRequest final
[Windows.Foundation.Metadata.Activatable(65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.None)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.STA)]
public sealed class DisplayRequest
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.None)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.STA)]
[Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
public sealed class DisplayRequest
function DisplayRequest()
Public NotInheritable Class DisplayRequest
상속
Object Platform::Object IInspectable DisplayRequest
특성

Windows 요구 사항

디바이스 패밀리
Windows 10 (10.0.10240.0에서 도입되었습니다.)
API contract
Windows.Foundation.UniversalApiContract (v1.0에서 도입되었습니다.)

예제

다음 코드( 디스플레이 전원 상태 샘플에서 가져온)는 디스플레이 요청을 활성화, 추적 및 해제하는 방법을 보여 줍니다.

/// <param name="sender"></param> 
/// <param name="e"></param> 
private void Activate_Click(object sender, RoutedEventArgs e)
{
    Error.Text = string.Empty;
    Button b = sender as Button;
    if (b != null)
    {
        try
        {
            if (g_DisplayRequest == null)
            {
                // This call creates an instance of the displayRequest object 
                g_DisplayRequest = new DisplayRequest();
            }
        }
        catch (Exception ex)
        {
            rootPage.NotifyUser("Error Creating Display Request: " + ex.Message, NotifyType.ErrorMessage);
        }

        if (g_DisplayRequest != null)
        {
            try
            {
                // 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;
                rootPage.NotifyUser("Display request activated (" + drCount + ")", NotifyType.StatusMessage);
            }
            catch (Exception ex)
            {
                rootPage.NotifyUser("Error: " + ex.Message, NotifyType.ErrorMessage);
            }
        }
    }
}

/// <param name="sender"></param> 
/// <param name="e"></param> 
private void Release_Click(object sender, RoutedEventArgs e)
{
    Error.Text = string.Empty;
    Button b = sender as Button;
    if (b != null)
    {
        if (g_DisplayRequest != null)
        {
            try
            {
                // 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. 
                g_DisplayRequest.RequestRelease();
                drCount -= 1;
                rootPage.NotifyUser("Display request released (" + drCount + ")", NotifyType.StatusMessage);
            }
            catch (Exception ex)
            {
                rootPage.NotifyUser("Error: " + ex.Message, NotifyType.ErrorMessage);
            }
        }
    }
}
''' <param name="sender"></param> 
''' <param name="e"></param> 
Private Sub Activate_Click(sender As Object, e As RoutedEventArgs) 
    ErrorTestBlock.Text = String.Empty 
    Dim b As Button = TryCast(sender, Button) 
    If b IsNot Nothing Then 
        Try 
            If g_DisplayRequest Is Nothing Then 
                ' This call creates an instance of the displayRequest object 
                g_DisplayRequest = New DisplayRequest() 
            End If 
        Catch ex As Exception 
            rootPage.NotifyUser("Error Creating Display Request: " & ex.Message, NotifyType.ErrorMessage) 
        End Try 

        If g_DisplayRequest IsNot Nothing Then 
            Try 
                ' 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 
                rootPage.NotifyUser("Display request activated (" & drCount & ")", NotifyType.StatusMessage) 
            Catch ex As Exception 
                rootPage.NotifyUser("Error:" & ex.Message, NotifyType.ErrorMessage) 
            End Try 
        End If 
    End If 
End Sub

''' <param name="sender"></param> 
''' <param name="e"></param> 
Private Sub Release_Click(sender As Object, e As RoutedEventArgs) 
    ErrorTestBlock.Text = String.Empty 
    Dim b As Button = TryCast(sender, Button) 
    If b IsNot Nothing Then 
        If g_DisplayRequest IsNot Nothing Then 
            Try 
                ' 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. 
                g_DisplayRequest.RequestRelease() 
                drCount -= 1 
                rootPage.NotifyUser("Display request released (" & drCount & ")", NotifyType.StatusMessage) 
            Catch ex As Exception 
                rootPage.NotifyUser("Error: " & ex.Message, NotifyType.ErrorMessage) 
            End Try 
        End If 
    End If 
End Sub 

설명

전원을 절약하고 배터리 수명을 연장하기 위해 시스템은 일정 시간 동안 사용자 활동을 감지하지 못하면 컴퓨터의 전원을 줄입니다. 시스템 전원 설정에 따라 디스플레이가 먼저 흐리게 표시되고, 화면 보호기가 표시될 수 있으며, 결국 시스템이 저전력 절전 상태로 전환되면 디스플레이가 꺼질 수 있습니다.

비디오를 표시하거나 사용자 입력 없이 장시간 실행되는 앱은 DisplayRequest.RequestActive를 호출하여 디스플레이가 계속 유지되도록 요청할 수 있습니다. 디스플레이 요청이 활성화되면 앱이 표시되는 동안 디바이스의 디스플레이가 켜져 있습니다. 사용자가 앱을 포그라운드 밖으로 이동하면 시스템에서 앱의 표시 요청을 비활성화하고 앱이 포그라운드로 돌아올 때 다시 활성화합니다.

표시 요청은 누적됩니다. 각 표시 요청은 DisplayRequest.RequestRelease에 대한 별도의 호출과 함께 해제되어야 합니다. 앱은 활성 디스플레이 요청 수를 추적하고 앱이 더 이상 디스플레이를 유지할 필요가 없을 때 모두 해제되었는지 확인해야 합니다(각각 DisplayRequest.RequestRelease에 대한 해당 호출 포함). 자세한 내용은 다음을 참조하세요.

디스플레이 요청을 사용하여 디스플레이를 켜두면 많은 전력이 소모됩니다. 표시 요청을 사용할 때 최상의 앱 동작을 위해 다음 지침을 사용합니다.

  • 필요한 경우에만 표시 요청을 사용합니다. 즉, 사용자 입력이 필요하지 않지만 디스플레이가 켜진 상태로 유지되어야 하는 시간입니다. 예를 들어 전체 화면 프레젠테이션 중 또는 사용자가 전자책을 읽는 경우입니다.
  • 더 이상 필요하지 않은 즉시 각 디스플레이 요청을 해제합니다.

참고

이 클래스는 민첩하지 않으므로 스레딩 모델 및 마샬링 동작을 고려해야 합니다. 자세한 내용은 스레딩 및 마샬링(C++/CX)다중 스레드 환경에서 Windows 런타임 개체 사용(.NET)을 참조하세요.

Windows Phone 8

이 API는 네이티브 앱에서만 지원됩니다.

생성자

DisplayRequest()

DisplayRequest 클래스의 instance 만듭니다.

메서드

RequestActive()

표시 요청을 활성화합니다.

RequestRelease()

표시 요청을 비활성화합니다.

적용 대상