中国优质的IT技术网站
专业IT技术创作平台
IT职业在线教育平台
宿主线程如何接收子线程发送的消息?
微信扫码分享
import worker, { MessageEvents } from '@ohos.worker'; workerInstance: worker.ThreadWorker = new worker.ThreadWorker('entry/ets/workers/Myworker.ets'); aboutToAppear(): void { this.workerInstance.onmessage = ((e: MessageEvents) => { //宿主线程接收子线程发来的消息 console.log("======"+JSON.stringify(e)) }) }