0

I'm working on a Console Application, and I would like to use a function that would activate the display (prevent from going to lock screen)

I Found the below script but it's only working for UWP Projects, Is there any equivelant for Console Application or any available NuGet Package manager Plugins that i can download for the same?

    private Windows.System.Display.DisplayRequest _displayRequest;

    public void ActivateDisplay()
    {
      //create the request instance if needed
      if (_displayRequest == null)
      _displayRequest = new Windows.System.Display.DisplayRequest();

      //make request to put in active state
     _displayRequest.RequestActive();
    }

    public void ReleaseDisplay()
    {
     //must be same instance, so quit if it doesn't exist
     if (_displayRequest == null)
       return;

     //undo the request
     _displayRequest.RequestRelease();
    }

Thank you very much

  • Your question is unclear. Do you simply want to prevent the screen saver from being triggered (which in turn will lock the session, depending on the user's settings), or do you want to literally make it impossible for the session to be locked, even by explicit action by the user? – Peter Duniho May 19 '20 at 01:43
  • I'm sorry, i want to prevent the screen going to "sleep mode" from being triggered . – AliAlnuaimi May 19 '20 at 01:47
  • @AhmedAbdelhameed i will try it and update here – AliAlnuaimi May 19 '20 at 01:47

0 Answers0