peekMessage
The peekMessage() function is used to receive messages from a thread.
peekMessage()
peekMessage(timeout)Examples
Concurrent thread sends messages to the main thread.
javascript
function main() {
var t1 = threading.Thread(function() {
for (var i = 0; i < 10; i++) {
Log("thread1 postMessage():", i)
threading.mainThread().postMessage(i)
Sleep(500)
}
})
while (true) {
var msg = threading.currentThread().peekMessage()
Log("main peekMessage():", msg)
if (msg == 9) {
break
}
Sleep(1000)
}
t1.join()
}Returns
| Type | Description |
string / number / bool / object / array / any (any type supported by the platform) | The |
Arguments
| Name | Type | Required | Description |
timeout | number | No | The |
See Also
Remarks
When writing programs, be careful to avoid thread deadlock issues.