CitrixWaitForDisconnect Function

Action

Waits for the ICA client to be disconnected from the Citrix server. This function must be used when a simulated user ends a session with a mouse click or key stroke (e.g. by closing a published application or selecting Log Off from the Start menu). When a session is to be actively closed (e.g. by closing the Citrix client), CitrixDisconnect must be called.

CitrixWaitForDisconnect waits until the disconnection takes place or the specified timeout period expires. In the case of a timeout, error reporting can be prohibited with the bNoError parameter.

Include file

CitrixAPI.bdh

Syntax

CitrixWaitForDisconnect( in nTimeout : number optional,
                         in bNoError : boolean optional ) : boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
nTimeout Specifies the time in milliseconds to wait for the disconnection (optional). When this parameter is omitted or set to 0, the default timeout is used. The default value can be adjusted by profile settings ( Settings > Active Profile > Citrix > General > Synchronization timeout ) or an appropriate call to the CitrixSetOption function.
bNoError Set this parameter to true to prevent a timeout from raising an error. This is especially useful for controlling variable user reactions.

Example:

  transaction TMain
  var
  begin
    CitrixInit(640, 480);
    CitrixConnect("myserver", "myusername", "mypass", "mydomain", COLOR_16bit);
    CitrixWaitForLogon();
    hWnd4 := CitrixWaitForWindowCreation("", MATCH_Exact, 0x96840000, -2, 452, 644, 30);
    hWnd5 := CitrixWaitForWindowCreation("ICA Seamless Host Agent", MATCH_Exact, 0x94C800C4, 0, 0, 390, 223);
    CitrixWaitForWindow(hWnd5, EVENT_Activate);
    CitrixWaitForWindowCreation("Program Manager");
    ThinkTime(3.33);
    CitrixMouseClick(208, 193, hWnd5, MOUSE_ButtonLeft);
    CitrixWaitForWindow(hWnd5, EVENT_Destroy);
    ThinkTime(2.45);
    CitrixMouseClick(41, 7, hWnd4, MOUSE_ButtonLeft);
    hWnd7 := CitrixWaitForWindowCreation("", MATCH_Exact, 0x96400000, 2, 193, 163, 263);
    CitrixMouseClick(48, 250, hWnd7, MOUSE_ButtonLeft);
    CitrixWaitForWindow(hWnd7, EVENT_Destroy);
    hWnd9 := CitrixWaitForWindowCreation("Shut Down Windows", MATCH_Exact, 0x94C808CC, 111, 96, 417, 192);
    CitrixWaitForWindow(hWnd9, EVENT_Activate);
    CitrixMouseClick(184, 165, hWnd9, MOUSE_ButtonLeft);
    CitrixWaitForDisconnect();
  end TMain;