c# - How do I cancel standby and hibernate? -
Using a third-party structure, my application is running in C #. It works as a UI for many applications. My question is when my notification is in progress and the system should not have standby / hinanet OS operating. Either way I have to cancel the event for extra / hinnate raised by the OS. Any person should help me in this regard.
Thanks Sun
It tells how to stop using the PC To use. Code looks like this:
Public partial squares Window 1: Window {Private UIT m_previousExecutionState; Public Window 1 () {InitializeComponent (); // Set the new state to stop system sleep (Note: still allows screen saver) m_previousExecutionState = NativeMethods.SetThreadExecutionState (NativeMethods.ES_CONTINUOUS | NativeMethods.ES_SYSTEM_REQUIRED); If (0 == M_Maximation ExecutionState) {message box. Show ("Call to Tothread ExecutionState failed unexpectedly.", Title, message box button. OK, messagebox image error.); // There is no way to recover; Close unlimited (); }} Safe Override Zero OnClosed (System.EventArgs e) {base.OnClosed (E); // Restore the previous state if (0 == basic methods .Setifffikation station (m_previousExecutionState)) {// No way to recover; Already Exiting}}} Internal Static Class Basic Methods {// Import Setthaddexation Station Windows API and Required Flags [DLIMport ("kernel 32.dll")] Public Static Exporter UIT Setthreadexcation Station (UIT Easflog); Public Trust UIT ES_CONTINUOUS = 0x80000000; Public Contest UISISISISEEEESEESEMEEHERD = 0x00000001; } If you liked the apps described in the post, there is an updated version.
Comments
Post a Comment