hibernate and stand by

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steve Teeples

    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
  • Willy Denoyette [MVP]

    #2
    Re: hibernate and stand by


    "Steve Teeples" <SteveT@newsgro ups.nospam> wrote in message
    news:218135A3-CDF7-48DD-9F14-26D000230CF5@mi crosoft.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.


    Comment

    • Steve Teeples

      #3
      Re: hibernate and stand by

      Is there a power management class in .NET 2.0?
      --
      -----------
      Thanks,
      Steve


      "Willy Denoyette [MVP]" wrote:
      [color=blue]
      >
      > "Steve Teeples" <SteveT@newsgro ups.nospam> wrote in message
      > news:218135A3-CDF7-48DD-9F14-26D000230CF5@mi crosoft.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.
      >
      >
      >[/color]

      Comment

      • Willy Denoyette [MVP]

        #4
        Re: hibernate and stand by

        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("Powr Prof")]
        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_APMQUERYSUS PEND event
        and suspend if all agree.

        Willy.


        "Steve Teeples" <SteveT@newsgro ups.nospam> wrote in message
        news:FCCCBC25-9BD7-463B-A979-3ADDC3678B50@mi crosoft.com...
        | Is there a power management class in .NET 2.0?
        | --
        | -----------
        | Thanks,
        | Steve
        |
        |
        | "Willy Denoyette [MVP]" wrote:
        |
        | >
        | > "Steve Teeples" <SteveT@newsgro ups.nospam> wrote in message
        | > news:218135A3-CDF7-48DD-9F14-26D000230CF5@mi crosoft.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.
        | >
        | >
        | >


        Comment

        • Steve Teeples

          #5
          Re: hibernate and stand by

          Thanks. This is just what I was looking for.
          --
          -----------
          Thanks,
          Steve


          "Willy Denoyette [MVP]" wrote:
          [color=blue]
          > 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("Powr Prof")]
          > 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_APMQUERYSUS PEND event
          > and suspend if all agree.
          >
          > Willy.
          >
          >
          > "Steve Teeples" <SteveT@newsgro ups.nospam> wrote in message
          > news:FCCCBC25-9BD7-463B-A979-3ADDC3678B50@mi crosoft.com...
          > | Is there a power management class in .NET 2.0?
          > | --
          > | -----------
          > | Thanks,
          > | Steve
          > |
          > |
          > | "Willy Denoyette [MVP]" wrote:
          > |
          > | >
          > | > "Steve Teeples" <SteveT@newsgro ups.nospam> wrote in message
          > | > news:218135A3-CDF7-48DD-9F14-26D000230CF5@mi crosoft.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.
          > | >
          > | >
          > | >
          >
          >
          >[/color]

          Comment

          • code4life
            New Member
            • Apr 2006
            • 7

            #6
            If you are using .NET 2.0 you can just call Application.Set SuspendState.

            Check out the documentation at:

            Comment

            Working...