Problem with SuspendingDeferral


  • The app has the following OnSuspending event handler:

    void App::OnSuspending(Object^ sender, SuspendingEventArgs^ e)
    	(void) sender;	// Unused parameter
    	(void) e;	// Unused parameter
    	//TODO: Save application state and stop any background activity
    	SuspendingDeferral^ deferral = e->SuspendingOperation->GetDeferral();

    It is nothing more than blank XAML application template with two lines added.


    when the app is suspended - via Visual Studio, for example, it hangs rather than suspends. The Task Manager shows the app as "Not responding" instead of "Suspended".

    Is it expected behaviour?

    Thursday, June 5, 2014 7:35 PM

All replies

  • I can't reproduce this.

    Do you get the same behavior if you suspend it normally rather than by using Visual Studio's mimicked suspensions?


    Friday, June 6, 2014 5:47 AM
  • This test application suspends normally when suspended without Visual Studio.

    But my "real" application did not, even after all custom code was disabled - only initial page left and the OnSuspending event handler, that also was reduced to the trivial code above.

    Now I tried it again, and it worked (real app with all real code disabled): when the app is suspended via Visual Studio, it "hangs", when it is suspended "normally" it suspends.

    But the question still remains: what does the OS wait for when executing the deferral->Complete() statement? It will be helpful when debugging.

    • Edited by Яков Friday, June 6, 2014 12:32 PM
    Friday, June 6, 2014 12:23 PM
  • See Application lifecycle

    In general the app is suspended when its suspending returns, unless there is a deferral in which case it suspends when the deferral completes. The app can also be terminated if it doesn't suspend in time.

    Showing not responding in Task Manager probably isn't a problem with the app but something environmental, but I don't have enough information to make a guess.


    Tuesday, June 10, 2014 10:47 PM