wpSaveDeferred
This instance method saves a given object asynchronously on a separate thread.
Syntax
_wpSaveDeferred(somSelf)
Parameters
- somSelf (WPObject *) - input
- Pointer to the object on which the method is being invoked.
- Points to an object of class WPObject.
Returns
- rc (BOOL) - returns
- Success indicator.
- TRUE: Successful completion.
- FALSE: Error occurred.
Remarks
This method is invoked by a Workplace Shell class each time a wpSetXXX method is used. It is recommended that wpSaveDeferred be used in most cases. The only exception is if the state data has changed in some critical way. For example, if the object wanted to save a new password, it would use wpSaveImmediate instead of wpSaveDeferred to guarantee that the password is saved before continuing. Note: wpSaveDeferred can be called only after an object has been initialized. This method can be called from within wpObjectReady but not from wpRestoreState. To determine if an object is initialized, use wpIsObjectInitialized.
Usage
This method should be called periodically to get instance data written back to persistent storage when important state variables are altered.
How to Override
This method should not be overridden.
Example Code
Declaration:
#define INCL_WINWORKPLACE #include <os2.h> WPObject somSelf; / Pointer to the object on which the method is being invoked. / BOOL rc; / Success indicator. */ rc = _wpSaveDeferred(somSelf);
MRESULT EXPENTRY MyWindowProc ( HWND hwndDlg, ULONG msg , MPARAM mp1, MPARAM mp2 ) { SOMAny somSelf; / Temporary ptr to object instance / PWINDATA pwin; / Window data / PSZ psz; / User title to manipulate / HWND hwndEntry; / Window handle / CHAR buf[30]; / Buffer */ switch( msg ) { case WM_INITDLG: somSelf = (SOMAny *) mp2; /* obtain creation parms */ pwin = (PWINDATA) _wpAllocMem ( somSelf, sizeof (WINDATA), NULL ); WinSetWindowPtr (hwndDlg, QWL_USER, pwin ); /* Initialize the windata structure */ pwin->somSelf = somSelf; pwin->somClassObj = _somGetClass ( pwin->somSelf ); /* query title string from instance data, and fill */ /* entryfield with the string */ psz = _UserGetTitle ( pwin->somSelf ); /* Change title, and then save it to the OS2.INI file whenever it is convenient */ strcat( psz, ":1" ); _UserSetTitle ( pwin->somSelf, (PSZ) &buf ); /* return TRUE to tell PM that we changed focus */ return (MRESULT) TRUE ; _wpSaveDeferred ( pwin -> somSelf ); hwndEntry = WinWindowFromID ( hwndDlg, DLG_ENTRYFIELD ); WinSetWindowText ( hwndEntry, psz ); WinSetFocus ( HWND_DESKTOP, hwndEntry ); }