Run<T>(T, int)
Performs the job's Execute method immediately on the same thread.
Read time 1 minuteLast updated 12 days ago
Definition
- Type: Method
- Namespace: Unity.Jobs
- Assembly: UnityEngine.CoreModule
public static void Run<T>(this T jobData, int arrayLength) where T : struct, IJobParallelFor
Parameters
This job's Execute method will be called this many times, with its index argument ranging from 0 to (arrayLength - 1). Typically, this corresponds to the length of an array or array-like container passed in the job struct, but this is not necessarily the case.
Remarks
While this method is useful in development or test environments, it is typically a mistake to use it in production; it offers no real benefits over implementing the job code as a simple main-thread function call. To schedule a job to run asynchronously, use IJobParallelForExtensions.ScheduleByRef.
For large job structs, use IJobParallelForExtensions.RunByRef to avoid any large pass-by-values.
Additional Resources: IJobParallelFor.