Type/to search
Built-in Functions
Global
Log
Market
Trade
Account
Futures
Exchange
IO
Network
Storage
Threads
exchange.Go
EventLoop
ctx.subscribe
ctx.poll
ctx.order
ctx.cancel
ctx.submit
Subscription
threading
Thread
Thread.peekMessage
Thread.postMessage
Thread.join
Thread.terminate
Thread.getData
Thread.setData
Thread.id
Thread.name
Thread.eventLoop
ThreadLock
ThreadEvent
ThreadCondition
ThreadDict
Server
TA
Talib
OS
Structures
Built-in Variables and Constants
Conventions
Exchanges

Receives 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

TypeDescription

string / number / bool / object / array / any

Messages received by the thread associated with the current thread object.

Arguments

NameTypeRequiredDescription

timeout

number

No

Timeout duration, blocking and waiting for data according to the milliseconds specified by this parameter; returns null if no data is received and timeout occurs. If timeout is set to 0 or the timeout parameter is not passed, it will block indefinitely until data is received from the channel. If timeout is set to -1, it will not block and returns immediately, returning null when there is no data.

See Also

Remarks

When writing programs, be careful to avoid thread deadlock issues.