Jump to content

wpWaitForClose

From EDM2
Revision as of 04:18, 17 November 2025 by Martini (talk | contribs) (Created page with "{{DISPLAYTITLE:wpWaitForClose}} This method is specific to version 3, or higher, of the OS/2 operating system. This instance method pauses the application until the specified views are closed or the timeout value is reached. ==Syntax== _wpWaitForClose(somSelf, lhView, ulViews, ulTimeOut, bAutoClose) ==Parameters== ;''somSelf'' (WPObject *) - input :Pointer to the object on which the method is being invoked. :Points to an object of class WPObject. ;''lhView''...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This method is specific to version 3, or higher, of the OS/2 operating system.

This instance method pauses the application until the specified views are closed or the timeout value is reached.

Syntax

_wpWaitForClose(somSelf, lhView, ulViews, ulTimeOut, bAutoClose)

Parameters

somSelf (WPObject *) - input
Pointer to the object on which the method is being invoked.
Points to an object of class WPObject.
lhView (LHANDLE) - input
Handle (**hwnd** or **happ**) of the view that must close before the application can continue.
If a value of **NULL** is passed, this method waits for all views of the specified type (**ulViews**) to close.
ulViews (ULONG) - input
Type of views to wait for.
This value is only used if **lhView** is **NULL**.
ulTimeOut (ULONG) - input
Time to wait for the views to close (in milliseconds). This is the maximum amount of time the user wants to allow the thread to be blocked.
This parameter can also have the following values:
  • **SEM_IMMEDIATE_RETURN** Returns immediately without blocking the calling thread.
  • **SEM_INDEFINITE_WAIT** Blocks the calling thread indefinitely.
bAutoClose (BOOL) - input
Flag indicating whether to automatically close.
This parameter should not be used as the standard method to close views. It exists **ONLY** to handle the possibility of a timing hole where all of the specified views are closed and another thread (probably due to user input) opens another view of the same type before **wpWaitForClose** returns.
Possible values are described in the following list:
  • **TRUE** **WM_Close** is posted for the views that are not presently closing, or **WinTerminateApp** is called on the applications that are being waited on.
  • **FALSE** Views that are not presently closing are not automatically closed.

Returns

Success (ULONG) - returns
Return value from **WinWaitEventSem** function.
This parameter can also have the following values:
  • **0** The view was closed successfully or was already closed when this method processed.
  • **-1** Error occurred.

How to Override

This method is generally not overridden.

Usage

This method can be called at any time.

Example Code

#define INCL_WINWORKPLACE
#include <os2.h>

WPObject *somSelf; /* Pointer to the object on which the method is being invoked. */
LHANDLE lhView; /* Handle (hwnd or happ) of the view that must close before the application can continue. */
ULONG ulViews; /* Type of views to wait for. */
ULONG ulTimeOut; /* Time to wait for the views to close. */
BOOL bAutoClose; /* Flag indicating whether to automatically close. */
ULONG Success; /* Return value from WinWaitEventSem function. */

Success = _wpWaitForClose(somSelf, lhView,
             ulViews, ulTimeOut, bAutoClose);

Remarks

When the specified views appear to have finished closing on the Desktop it might seems that the method is hung. This is because closing the multithreading process may require additional time to complete. If a view is in the process of closing, and you must wait for that view to finish closing before you can continue processing, this method can be called to act as an event semaphore. It can also be used to block the thread until a program exits when executed from a program object.