Question

I want to simulate ApplicationExecutionState.Terminated state.

I am doing following
1. Launching the app
2. Navigating to Desktop, waiting for App to be in suspended state
3. Killing the app using End Task from Task Manager.

This application is used for a demonstration, and previously it was in Consumer preview. At that time, above steps worked good.

Now, in Windows 8 RTM, using above steps, ApplicationExecutionState is coming to be NotRunning.

I want to know how to the Terminated state?

I am already aware of following
1. By using simulator, First getting the app suspended, and then logging off from simulator.
2. By putting memory pressure in windows. This way the app will automatically get terminated. Problem is that I do-not know, how to put memory pressure.

Was it helpful?

Solution 2

From this Microsoft forum question:

Terminated means that the app was first suspended, and then the user Session ended normally.

To simulate this in the debugger, you can run your app in the simulator and then trigger a suspend (Debug, Trigger Suspend). Then you can log off of the simulator. You can then fire up the simulator again in the debugger and see you hit the condition that you came from a previous state of 'Terminated'.

Alternatively, you can use the tool available At winrt.codeplex.com

[Update: 2013-03-11 @ 11:02PST]

It's important to understand that in the Windows 8 App Lifecycle, the ApplicationExecutionState enumeration indicates the state of the app last time the process exited (via several objects' PreviousExecutionState property ).

The only way to simulate this state is to suspend your app, log-off and log back in again and restart the app or you could simulate a system under load by using/writing an app that can consume a considerable portion of the available physical RAM, forcing Windows to try and reclaim resources by force-terminating suspended apps.

To stress your machine out and consume large amounts of memory etc., you could use the consume.exe command-line app that comes in the Windows SDK or use James McCaffrey's EatMem tool.

OTHER TIPS

To trigger Suspend and shutdown as well as other process lifetime management events during debugging, use the Debug Location toolbar in Visual Studio. Next to the Process dropbox there's a dropdown button containing the above mentioned command:

Process lifecycle management commands

There's no need to use the simulator for this to work. You can run the app on your local machine just as well.

You can read more about this and the other commands in the dropdown button in this MSDN article.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top