locked
Event to be caught when app is dragged to bottom of screen

    Question

  • Hi all,

    what is the event one can catch in Windows 8 (JavaScript / HTML) when dragging an app down to the bottom of the screen?

    How can I save state in such a case (currently it works for me on suspend)

    Thanks

    Thomas

    Wednesday, April 10, 2013 6:51 PM

Answers

  • Probably because you're running in the debugger, where suspend doesn't happen as it normally would. If you have some app state (e.g. a test file) that you create in suspend, then run the app outside of the debugger and verify that suspend is happening.
    Wednesday, April 10, 2013 9:14 PM
  • When the user closes an app with this gesture or Alt+F4, Windows first hides the app, then suspends it, then closes it. So if you're saving state in the suspending event, then you're covered, as there isn't a distinct event for close.

    It's recommended that you save state incrementally if you can, to minimize the work needed on suspend. One reason for this is that if the user closes an app with this gesture, but quickly starts it again (within 10 seconds), Windows might terminate the app without suspend necessarily finishing. This is the case where the previousExecutionState will be notRunning rather than closedByUser (as happens if the app is fully shut down in response to a close).

    Kraig

    Author, Programming Windows 8 Apps with HTML, CSS, and JavaScript, a free ebook from Microsoft Press


    Wednesday, April 10, 2013 7:49 PM

All replies

  • When the user closes an app with this gesture or Alt+F4, Windows first hides the app, then suspends it, then closes it. So if you're saving state in the suspending event, then you're covered, as there isn't a distinct event for close.

    It's recommended that you save state incrementally if you can, to minimize the work needed on suspend. One reason for this is that if the user closes an app with this gesture, but quickly starts it again (within 10 seconds), Windows might terminate the app without suspend necessarily finishing. This is the case where the previousExecutionState will be notRunning rather than closedByUser (as happens if the app is fully shut down in response to a close).

    Kraig

    Author, Programming Windows 8 Apps with HTML, CSS, and JavaScript, a free ebook from Microsoft Press


    Wednesday, April 10, 2013 7:49 PM
  • Hi Kraig,

    Thanks for this clear answer! Do you happen to know why a breakpoint set within suspend is not caught when dragging the app down to the bottom of the screen?

    Best regards,

    Thomas

    Wednesday, April 10, 2013 8:43 PM
  • Probably because you're running in the debugger, where suspend doesn't happen as it normally would. If you have some app state (e.g. a test file) that you create in suspend, then run the app outside of the debugger and verify that suspend is happening.
    Wednesday, April 10, 2013 9:14 PM
  • Thanks Kraig, very useful answers I am getting here in these forums :)
    Thursday, April 11, 2013 7:50 AM