Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Revision as of 02:30, 16 November 2011 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

How to retrieve a list of currently running tasks?

From Wiki
Jump to: navigation, search
Article Metadata
Created: eswar_illuri (25 May 2007)
Last edited: hamishwillee (16 Nov 2011)
A list of currently running tasks can be retrieved with TApaTaskList class. A task is identified by its association with the running application's window group. A session to the window server needs to be passed to TApaTaskList during construction.

#include <apgtask.h>    // link against apgrfx.lib
TApaTaskList tasklist(CCoeEnv::Static()->WsSession());
TApaTask taskInForeground = tasklist.FindByPos( 0 );
// Window Group ID of the foreground task
TInt WindowGroupIdentifier = taskInForeground.WgId();
// Thread ID of the foreground task
TThreadId ThreadIdentifier = taskInForeground.ThreadId();

The first task in TApaTaskList is the one in foreground (the associated window group has ordinal position 0).

TApaTask contains some information about the task. For example, the thread identifier (ThreadId()) and window group identifier (WgId()).

Furthermore, there are useful methods such as EndTask() that requests the task to close normally, and KillTask() that directly terminates the task. SendToBackground() and BringToForeground() can be used for controlling the application's position in the task list.

Other Related Links

Tasks (running GUI application), how to find them

This page was last modified on 16 November 2011, at 02:30.
21 page views in the last 30 days.