hibernate and stand by

G

Guest

Does someone have an example of C# code (VS 2005) that puts a system into
hibernation or stand by and then after some period of time wakes up the
system?

I need to write a test that does this functionality.
 
W

Willy Denoyette [MVP]

| Does someone have an example of C# code (VS 2005) that puts a system into
| hibernation or stand by and then after some period of time wakes up the
| system?
|
| I need to write a test that does this functionality.
|
| --
| -----------
| Thanks,
| Steve

As far as I know, there is no way to enter standby/hibernate state from user
code, that is without user intervention. You can awake a system by using a
timer (System.Timers.Timer or Threading.Timer), a system in standby or
hibernate state will wake up at the next timer event.

Willy.
 
W

Willy Denoyette [MVP]

No, but there is a Win32 API to set this state, provided your system is ACPI
compliant and the BIOS is set-up to enable S4 and/or S3.

Here is the declaration (not tested!)....

[DllImport("PowrProf")]
extern static bool SetSuspendState( bool hibernate, bool force , bool
disablewakeup );

usage:

SetSuspendState(true, true, false); // force hibernate, disable all wakeup
events
SetSuspendState(false, true, true); // force suspend and enable wake events.
SetSuspendState(false, false, true); // broadcast PBT_APMQUERYSUSPEND event
and suspend if all agree.

Willy.


| Is there a power management class in .NET 2.0?
| --
| -----------
| Thanks,
| Steve
|
|
| "Willy Denoyette [MVP]" wrote:
|
| >
| > | > | Does someone have an example of C# code (VS 2005) that puts a system
into
| > | hibernation or stand by and then after some period of time wakes up
the
| > | system?
| > |
| > | I need to write a test that does this functionality.
| > |
| > | --
| > | -----------
| > | Thanks,
| > | Steve
| >
| > As far as I know, there is no way to enter standby/hibernate state from
user
| > code, that is without user intervention. You can awake a system by using
a
| > timer (System.Timers.Timer or Threading.Timer), a system in standby or
| > hibernate state will wake up at the next timer event.
| >
| > Willy.
| >
| >
| >
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top