Class

Worker


Description

Use a Worker to run code on multiple CPU cores.

Note

This class is not currently supported for Windows on ARM.

Methods

Name

Parameters

Returns

Shared

SendJobCompleted

jobResult As String

SendProgress

progressData As String

Start

Stop

Events

Name

Parameters

Returns

Error

jobData As String

JobCompleted

jobResult As String

JobProgressed

progressData As String

JobRequested

JobRun

jobData As String

Property descriptions


Worker.CorePercent

CorePercent As Integer

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


Worker.MaximumCoreCount

MaximumCoreCount As 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.


Worker.ProjectItemsToInclude

ProjectItemsToInclude As String

List of Project Items to include in the Worker Console app. By default all classes and modules are copied over, but for larger projects you will likely prefer to only copy over what is needed by the Worker to reduce compilation time and app size. Enter one project item per line.

Method descriptions


Worker.SendJobCompleted

SendJobCompleted(jobResult As String)

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


Worker.SendProgress

SendProgress(progressData As 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).


Worker.Start

Start

Starts the Worker by creating the separate helpers based on your core settings.


Worker.Stop

Stop

Stops the Worker and all its helpers.

Event descriptions


Worker.Error

Error(jobData As String)

If there is an error, the job data is provided here so you can determine which job caused the error.


Worker.JobCompleted

JobCompleted(jobResult As 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.


Worker.JobProgressed

JobProgressed(progressData As String)

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


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 Worker should quit.

The encoding of the jobData that you return is not preserved. Apply the encoding in JobRun as necessary.


Worker.JobRun

JobRun(jobData As 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.

Compatibility

All project types on all supported operating systems.