An application can bring a session to the foreground, or select the session, by calling DosSelectSession.

DosSelectSession can only be used to select the current session or one of the current session's child sessions. It cannot be used to select a grandchild session, or any other descendant session beyond a child session, or any sessions that were started as unrelated sessions.

The session making the call, or one of its child sessions, must be executing in the foreground at the time the function is called. A process can call DosSelectSession with its own session identifier to switch itself to the foreground when one of its descendants is executing in the foreground.

The following code fragment uses DosSelectSession to switch the child session specified by the ulSessionID parameter to the foreground for five seconds. The application then switches the parent session back to the foreground:

    #define INCL_DOSPROCESS         /* Process and thread values   */
    #include <os2.h>

    ULONG ulSessionID;

    DosSelectSession(ulSessionID);   /* Switches child to foreground */
    DosSleep(5000);                  /* Sleeps for 5 seconds         */
    DosSelectSession(0);             /* Switches parent back         */


[Back] [Next]