How to get a list of running tasks

From: http://wiki.forum.nokia.com/index.php/%E5%A6%82%E4%BD%95%E8%8E%B7%E5%8F%96%E6%AD%A3%E5 %9C%A8%E8%BF%90%E8%A1%8C%E4%BB%BB%E5%8A%A1%E7%9A%84%E5%88%97%E8%A1%A8

  • Equipment, software version:

S60 1st Edition S60 2nd Edition and FP1, FP2, FP3 S60 3rd Edition and FP1

Series 80 2nd Edition


  • Detailed Description:

description

The application framework of the Symbian operating system provides a set of APIs to obtain information about the currently running task (whether it is running in the foreground or background).


 solution

We can use TApaTaskList to get a list of currently running tasks. The specific task is identified by the window group of the running program. When constructing the TApaTaskList, we need to pass the session of the window server as a parameter.

 
  
  
#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 that runs in the foreground (the position order of the relevant window group starts from 0)

TApaTask includes a lot of useful information related to the task, such as thread ID (ThreadId()) and window group ID (WgId()).

In addition, there are some useful functions, such as EndTask(), which is used to request the normal shutdown of a task, and KillTask(), which is used to directly terminate a task.

The SendToBackground() and BringToForeground() methods can be used to control the position of the program in the task list. 

Guess you like

Origin blog.csdn.net/windcao/article/details/1804523