This method has two forms: WinJS.Promise.timeout(timeout) and WinJS.Promise.timeout(timeout, promise). WinJS.Promise.timeout(timeout) creates a promise that is completed asynchronously after the specified timeout, essentially wrapping a call to setTimeout within a promise. WinJS.Promise.timeout(timeout, promise) sets a timeout period for completion of the specified promise, automatically canceling the promise if it is not completed within the timeout period.
Syntax
promise.timeout(timeout, promise).done( /* Your success and error handlers */ );
Parameters
- timeout
-
Type: Number
The timeout period in milliseconds. If this value is zero or not specified, msSetImmediate is called, otherwise setTimeout is called.
- promise
-
Type: Promise
Optional. A promise that will be canceled if it doesn't complete within the timeout period.
Return value
Type: Promise
If the promise parameter is omitted, returns a promise that will be fulfilled after the timeout period. If the promise paramater is provided, the same promise is returned.
Remarks
For more information, see Setting timeout values with WinJS.xhr.
WinJS.Promise.timeout(interval).then(
function(complete) {
// code that executes after the timeout has completed.
},
function (error) {
// code that takes care of the canceled promise.
// Note that .then rather than .done should be used in this case.
});
WinJS.Promise.timeout(interval, promise).done( function(complete) { // code that executes after the promise has completed. });
Requirements
|
Minimum supported client | Windows 8 [Windows Store apps only] |
|---|---|
|
Minimum supported server | Windows Server 2012 [Windows Store apps only] |
|
Namespace |
WinJS |
|
Library |
|
See also
Build date: 12/5/2012