Lines Matching refs:worker

78 1. In DevEco Studio, add a worker named **MyWorker** to your project.
82 2. In the main thread, call [constructor()](../reference/apis-arkts/js-apis-worker.md#constructor9)…
86 import { worker } from '@kit.ArkTS';
88 …const workerInstance: worker.ThreadWorker = new worker.ThreadWorker('entry/ets/workers/MyWorker.ts…
91worker.md#onmessage9) to receive messages from the worker thread, and call [postMessage()](../refe…
92 …sends training and prediction messages to the worker thread, and receives messages sent back by th…
98 // Receive the result from the worker thread.
108 // Receive error information from the worker thread.
111 // Send a training message to the worker thread.
115 4. Bind the **Worker** object in the **MyWorker.ts** file. The calling thread is the worker thread.
119 import { worker, ThreadWorkerGlobalScope, MessageEvents, ErrorEvent } from '@kit.ArkTS';
121 let workerPort: ThreadWorkerGlobalScope = worker.workerPort;
124worker thread, call [onmessage()](../reference/apis-arkts/js-apis-worker.md#onmessage9-1) to recei…
125 …For example, the prediction model and its training process are defined in the worker thread, and m…
139 // onmessage logic of the worker thread.
162 6. After the task is completed in the worker thread, destroy the worker thread. The worker thread c…
164 …](../reference/apis-arkts/js-apis-worker.md#onexit9) in the host thread to define the processing l…
167 // After the worker thread is destroyed, execute the onexit() callback.
173 …inate()](../reference/apis-arkts/js-apis-worker.md#terminate9) to destroy the worker thread and st…
176 // Destroy the worker thread.
180 …d 2: In the worker thread, call [close()](../reference/apis-arkts/js-apis-worker.md#close9) to des…
183 // Destroy the worker thread.