471,319 Members | 1,831 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,319 software developers and data experts.

hibernate and stand by

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
5 9745

"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
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
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
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
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.

Similar topics

1 post views Thread by Keith Simeon | last post: by
1 post views Thread by chandukandula | last post: by
rsrinivasan
6 posts views Thread by rsrinivasan | last post: by
oll3i
2 posts views Thread by oll3i | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.