none
C#, Execute Code before Connected Standby, Tablet-PC RRS feed

  • Question

  • Hi,

    I have a new Asus VivoTab 8, and some trouble with the connected Standby:

    I want to execute some code when the Tablet is send to "Connected Standby" and Resumes its work. 

    The Code is C# and basically is built around this lines:

    SystemEvents.PowerModeChanged += new PowerModeChangedEventHandler(

        SystemEvents_PowerModeChanged

    );

     

    void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)

            {

                            switch (e.Mode)

                {

                .... and so on...

               

               

               

     

     e.Mode  will be an enum of one of "Resume", "StatusChange" or "Suspend"

     

    But this only works when I set the Tablet to Hibernate, simply pressing the Power Button doesn't trigger the Events 

    Using a Windows 7 Machine, the Code works fine too! 

    I also tried the WM_POWERBROADCAST... Messages, no Success...

    Is there any way to react when Tablet goes to Connected Standby?

     

    Thanks

    Frank(ly)

    Monday, May 19, 2014 10:54 AM

All replies

  • Hello,

    For this issue, I am trying to invoke someone experienced to help look into this thread, if we have any result, we will tell you.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, May 20, 2014 9:22 AM
    Moderator
  • Hi Franz96,

    I don't have a Asus VivoTab 8 to test. Just did a quick test on Lenovo X1, but it seems the event works well.

    I just created a simple windows form application and put a text box on the form. Then I will print out the e.Mode in the textbox. Like: textBox1.Text = texBox1.Text + e.Mode.ToString() in c#.

    I tried to sleep the windows from setting panel and also tried pressing the power button. Then I get the following text:

    "SuspendResumeSuspendResume"

    So it looks good. Could you please try if the method above works for you?

    And let me know how you determine if it works or not.


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    Alan Yao
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Wednesday, May 21, 2014 7:01 AM
  • Thank you for your reply, but I'm not sure if the X1 supports Connected Standy, because it's a very new feature
    could you confirm that your PC is supporting/using Connected Standby?

    at command Prompt:

    type

    powercfg /availablesleepstates

    Look for "Standby (Connected)"

    Unfortunately I don't have my Tablet-PC at hand right now :(


    • Edited by Franz96 Wednesday, May 21, 2014 10:27 AM
    Wednesday, May 21, 2014 9:20 AM
  • Thank you Pavel!
    It's a desktop application.
    As far as I understand I should use the "RegisterSuspendResumeNotification" function

    But I'll need some time to check it out.

    Update:

    Yes it works, using RegisterSuspendResumeNotification, it get's me back the Powerbroastcast Messages:

    Win 8 only!

    private int DEVICE_NOTIFY_WINDOW_HANDLE = 0x00000000;

    RegisterSuspendResumeNotification(this.Handle, DEVICE_NOTIFY_WINDOW_HANDLE);

    The relevant information is in the link "Learn more about CS" from Pavel.

    Thanks & happy for the moment.

    • Edited by Franz96 Saturday, May 24, 2014 3:24 PM
    Thursday, May 22, 2014 12:29 PM