Class
Worker
Description
Use a Worker to run code on multiple CPU cores.
Properties
Name |
Type |
Read-Only |
Shared |
---|---|---|---|
Events
Name |
Parameters |
Returns |
---|---|---|
jobData As String |
||
jobResult As String |
||
progressData As String |
||
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. No classes or modules are included by default. Enter one project item per line. To include all classes and modules, enter IncludeAllClassesAndModules
.
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.
Note
This event runs in your application, not in the worker console application.
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.
Note
This event runs in your application, not in the worker console application.
Worker.JobProgressed
JobProgressed(progressData As String)
Called by SendProgress() method to provide information about the progress of the job.
Note
This event runs in your application, not in the worker console application.
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.
Note
This event runs in your application, not in the worker console application.
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.
Note
This event runs in the worker console application, not in your application.
Compatibility
Desktop projects on all supported operating systems.
See also
Object parent class; Faster Processing using the Worker Class