資源の読み込みに... 荷物...

投稿メッセージ



postMessage(msg)

参数```msg```为所要发送的消息。

msg
true
string、number、bool、object、array、function、空值等系统支持的任意类型

```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)
        }        
    })
    for (var i = 0; i < 10; i++) {
        var event = threading.mainThread().eventLoop()
        Log("main event:", event)
        Sleep(500)
    }
    t1.join()
}

メッセージを送信し,使います.eventLoop()ニュースの通知を受け取る.

function main() {
    threading.mainThread().postMessage(function(msg) {
        Log("func from mainThread, msg:", msg)
    })
    
    threading.Thread(function() {
        var func = threading.mainThread().peekMessage()
        func("in " + threading.currentThread().name())
    }).join()
}

函数を送信するサポート.

実行関数に呼び出します.postMessage()函数が信号,データを送信するときにメッセージイベントも発生します.eventLoop()機能はメッセージ通知を受け取ります.

{@fun/Threads/Thread/peekMessage peekMessage}, {@fun/Threads/Thread/join join}, {@fun/Threads/Thread/terminate terminate}, {@fun/Threads/Thread/getData getData}, {@fun/Threads/Thread/setData set}, {@fun/Threads/Thread/id id}, {@fun/Threads/Threads/Thread/name name join}, {@fun/Threads/Thread/terminate terminate}, {@fun/Threads/Thread/getData getData}, {@fun/Threads/Thread/setData setData}, {@fun/Threads/Threads/id id}, {@fun/Threads/Threads/Threads/name name}, {@fun/Threads/Thread/eventLoop eventLoop}

peek メッセージ 加入する