By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,760 Members | 955 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,760 IT Pros & Developers. It's quick & easy.

hibernate and stand by

P: n/a
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
Feb 2 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a

"Steve Teeples" <St****@newsgroups.nospam> wrote in message
news:21**********************************@microsof t.com...
| 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.
Feb 2 '06 #2

P: n/a
Is there a power management class in .NET 2.0?
--
-----------
Thanks,
Steve
"Willy Denoyette [MVP]" wrote:

"Steve Teeples" <St****@newsgroups.nospam> wrote in message
news:21**********************************@microsof t.com...
| 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.

Feb 2 '06 #3

P: n/a
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.
"Steve Teeples" <St****@newsgroups.nospam> wrote in message
news:FC**********************************@microsof t.com...
| Is there a power management class in .NET 2.0?
| --
| -----------
| Thanks,
| Steve
|
|
| "Willy Denoyette [MVP]" wrote:
|
| >
| > "Steve Teeples" <St****@newsgroups.nospam> wrote in message
| > news:21**********************************@microsof t.com...
| > | 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.
| >
| >
| >
Feb 2 '06 #4

P: n/a
Thanks. This is just what I was looking for.
--
-----------
Thanks,
Steve
"Willy Denoyette [MVP]" wrote:
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.
"Steve Teeples" <St****@newsgroups.nospam> wrote in message
news:FC**********************************@microsof t.com...
| Is there a power management class in .NET 2.0?
| --
| -----------
| Thanks,
| Steve
|
|
| "Willy Denoyette [MVP]" wrote:
|
| >
| > "Steve Teeples" <St****@newsgroups.nospam> wrote in message
| > news:21**********************************@microsof t.com...
| > | 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.
| >
| >
| >

Feb 2 '06 #5

P: 7
If you are using .NET 2.0 you can just call Application.SetSuspendState.

Check out the documentation at:
http://msdn2.microsoft.com/en-us/lib...pendstate.aspx
Apr 27 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.