HomeWiki
HomeWiki
  1. Utils
  • Back to home
  • 2. Connectivity
  • Introduction
  • Custom Script
  • Playground
  • Database Explorer
  • Log Stream
  • Direct Communication
  • Softone
    • Getting Started
  • Datapump
    • Getting Started
    • Crons
    • Legacy Windows Support
    • SDK
      • DB
        • _executeQuery
        • _executeStoreProcedure
        • _executeInsertQuery
        • _executeInsertQueriesInTransaction
      • Import
        • _productsImport
        • _categoriesImport
        • _brandsImport
        • _attributesImport
        • _attributeSetsImport
        • _unitsImport
        • _quantityImport
        • _customersImport
        • _contactsImport
        • _callsImport
        • _eventsImport
        • _tasksImport
        • _ordersImport
        • _usersImport
        • _customerSourceTagsImport
        • _productSourceTagsImport
      • Log
        • _logDebug
        • _logInfo
        • _logWarn
        • _logError
      • Web Requests
        • _httpGetJson
        • _httpPostJson
        • _httpPutJson
        • _httpDeleteJson
        • _httpPatchJson
      • Variables
        • _saveVariable
        • _getVariable
        • _deleteVariable
      • Blob
        • _blobConnect
        • _blobExists
        • _blobGet
        • _blobFind
      • Utils
        • _encodeBase64
        • _sleep
        • _getLastSyncDate
        • _updateLastSyncDate
        • _resetLastSyncDate
  1. Utils

_sleep

Documentation: _sleep Function#

The _sleep function pauses the execution of the program for a specified amount of time. This can be useful for introducing delays in the execution flow, such as waiting for a specific condition to be met or simulating processing time.

Function Signature:#

Parameters:#

milliseconds:
Description: The amount of time, in milliseconds, for which the function should pause the execution. The function will block the current thread or process for this duration.
Type: number
Example:

Return Value:#

Returns:
The function does not return any value.
Type: void

Function Workflow:#

1.
Receive Duration:
The function receives the duration for which it needs to pause execution, provided in milliseconds.
2.
Pause Execution:
The function halts the execution of the program for the specified duration. This is done synchronously, meaning that the program will not proceed to the next operation until the pause is complete.
3.
Resume Execution:
After the specified time has elapsed, the function allows the program to continue execution.

Example Usage:#

Important Considerations:#

Blocking Behavior:
_sleep pauses the entire thread or process, which means that no other operations can occur during this time. Use this function with caution, especially in environments where non-blocking behavior is required.
Accuracy:
The actual sleep time might slightly differ from the specified duration due to scheduling and system timing inaccuracies.
Usage Context:
The _sleep function is suitable for scenarios where you need a deliberate delay. For asynchronous operations or non-blocking delays, consider using asynchronous patterns or timers.
By using _sleep, you can control the timing of your program's execution, introducing delays where necessary to synchronize operations or simulate processing times.
Modified at 2024-08-23 12:29:04
Previous
_encodeBase64
Next
_getLastSyncDate
Built with