c# - Suspending event not raising using WinRT -


i'm having problem suspending event on windows phone 8.1 using winrt, not fire. don't know why. code:

/// <summary> /// initializes singleton application object. first line of authored code /// executed, , such logical equivalent of main() or winmain(). /// </summary> public app() {     initializecomponent();      suspending += onsuspending; #if debug     this.displayrequest = new displayrequest(); #endif }  /// <summary> /// invoked when application execution being suspended. application state saved /// without knowing whether application terminated or resumed contents /// of memory still intact. /// </summary> /// <param name="sender"> /// source of suspend request. /// </param> /// <param name="e"> /// details suspend request. /// </param> private void onsuspending(object sender, suspendingeventargs e) {     var deferral = e.suspendingoperation.getdeferral();     deferral.complete(); } 

i set breakpoint on line var deferral = e.suspendingoperation.getdeferral(); , debugged visual studio. pressed start button on phone , ran app , waited 10 seconds. onsuspending not running.

any ideas?

suspending event won't fire while debugging (but while running app normal, fire after navigate away app) said @ this blog:

...you wait forever these trigger, though app switches , forth screen! reason simple: while app being debugged, windows not suspend it.

note may lead weird app behavior, when there wrong in suspending event - example if pass complex class in frame.navigate method , use suspensionmanager. while debugging app work fine (no suspension), crash without debug mode.

to test how app behaves, have invoke suspending manuallt, open (or set visible) debug location toolbar in visual studio, there find dropdown lifecyce events, choose there suspend, , return app - resume.

enter image description here


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -