Class

# Worker

<div class="rst-class">

forsearch

</div>

Multicore

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Use a <span class="title-ref">Worker</span> to run code on multiple CPU cores.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                                  | Type                               | Read-Only | Shared |
|-------------------------------------------------------|------------------------------------|-----------|--------|
| `CorePercent<worker.corepercent>`                     | `Integer</api/data_types/integer>` |           |        |
| `MaximumCoreCount<worker.maximumcorecount>`           | `Integer</api/data_types/integer>` |           |        |
| `ProjectItemsToInclude<worker.projectitemstoinclude>` | `String</api/data_types/string>`   |           |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                        | Parameters                                       | Returns | Shared |
|---------------------------------------------|--------------------------------------------------|---------|--------|
| `SendJobCompleted<worker.sendjobcompleted>` | jobResult As `String</api/data_types/string>`    |         |        |
| `SendProgress<worker.sendprogress>`         | progressData As `String</api/data_types/string>` |         |        |
| `Start<worker.start>`                       |                                                  |         |        |
| `Stop<worker.stop>`                         |                                                  |         |        |

## Events

<div class="rst-class">

table-centered_column_4

</div>

| Name                                  | Parameters                                       | Returns |
|---------------------------------------|--------------------------------------------------|---------|
| `Error<worker.error>`                 | jobData As `String</api/data_types/string>`      |         |
| `JobCompleted<worker.jobcompleted>`   | jobResult As `String</api/data_types/string>`    |         |
| `JobProgressed<worker.jobprogressed>` | progressData As `String</api/data_types/string>` |         |
| `JobRequested<worker.jobrequested>`   |                                                  |         |
| `JobRun<worker.jobrun>`               | jobData As `String</api/data_types/string>`      |         |

## Property descriptions

<div id="worker.corepercent">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Worker.CorePercent

**CorePercent** As `Integer</api/data_types/integer>`

> The the maximum number of cores to use expressed as a percent of total CPU cores.

<div id="worker.maximumcorecount">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Worker.MaximumCoreCount

**MaximumCoreCount** As `Integer</api/data_types/integer>`

> The maximum number of cores to use. Regardless of the percent, this is the most CPU cores that will be used. This should be 1 or greater.

<div id="worker.projectitemstoinclude">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Worker.ProjectItemsToInclude

**ProjectItemsToInclude** As `String</api/data_types/string>`

> List of Project Items to include in the <span class="title-ref">Worker</span> Console app. No classes or modules are included by default. Enter one project item per line. To include all classes and modules, enter `IncludeAllClassesAndModules`.

## Method descriptions

<div id="worker.sendjobcompleted">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Worker.SendJobCompleted

**SendJobCompleted**(jobResult As `String</api/data_types/string>`)

> Manually call JobCompleted event sending along the result in the parameter.

<div id="worker.sendprogress">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Worker.SendProgress

**SendProgress**(progressData As `String</api/data_types/string>`)

> Calls the JobProgressed event sending along the data in the parameter. This should only be called from the JobRun event (or methods it calls from the event).

<div id="worker.start">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Worker.Start

**Start**

> Starts the <span class="title-ref">Worker</span> by creating the separate helpers based on your core settings.

<div id="worker.stop">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Worker.Stop

**Stop**

> Stops the <span class="title-ref">Worker</span> and all its helpers.

## Event descriptions

<div id="worker.error">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Worker.Error

**Error**(jobData As `String</api/data_types/string>`)

> If there is an error, the job data is provided here so you can determine which job caused the error.
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> This event runs in your application, not in the worker console application.
>
> </div>

<div id="worker.jobcompleted">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Worker.JobCompleted

**JobCompleted**(jobResult As `String</api/data_types/string>`)

> Called when JobRun completes and contains the results returned by JobRun.
>
> The encoding of the *jobResult* that is not preserved from the value returned by JobRun. Apply the encoding as necessary.
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> This event runs in your application, not in the worker console application.
>
> </div>

<div id="worker.jobprogressed">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Worker.JobProgressed

**JobProgressed**(progressData As `String</api/data_types/string>`)

> Called by SendProgress method to provide information about the progress of the job.

<div class="note">

<div class="title">

Note

</div>

This event runs in your application, not in the worker console application.

</div>

<div id="worker.jobrequested">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Worker.JobRequested

**JobRequested**

> Return something that indicates the job to process. This information is supplied as the parameter to JobRun. You should avoid passing around large chunks of data as that will not be memory efficient. If you have large data (pictures, data, databases, etc.) then pass along information on how to get the data using other means such as file access or connecting to the database and fetching what is needed. Returning an empty string indicates that there are no more jobs to process and that the <span class="title-ref">Worker</span> should quit.
>
> The encoding of the jobData that you return is not preserved. Apply the encoding in JobRun as necessary.
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> This event runs in your application, not in the worker console application.
>
> </div>

<div id="worker.jobrun">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Worker.JobRun

**JobRun**(jobData As `String</api/data_types/string>`)

> When a job is completed, the JobCompleted event is called passing along the results returned from JobRun.
>
> The *jobData* that you receive has no encoding. Apply the encoding as necessary.
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> This event runs in the worker console application, not in your application.
>
> </div>

## Compatibility

|                       |         |
|-----------------------|---------|
| **Project Types**     | Desktop |
| **Operating Systems** | All     |

<div class="seealso">

`Object</api/data_types/additional_types/object>` parent class; `Faster Processing using the Worker Class</topics/data_processing/faster_processing_using_the_worker_class>`

</div>
