To schedule a job, you must:
Calling Schedule
puts the job into the job queue for execution at the appropriate time. Once scheduled, you cannot interrupt a job.
Note: You can not call Schedule
from within jobs.
// Create a native array of a single float to store the result. This example waits for the job to complete for illustration purposes
NativeArray<float> result = new NativeArray<float>(1, Allocator.TempJob);
// Set up the job data
MyJob jobData = new MyJob();
jobData.a = 10;
jobData.b = 10;
jobData.result = result;
// Schedule the job
JobHandle handle = jobData.Schedule();
// Wait for the job to complete
handle.Complete();
// All copies of the NativeArray point to the same memory, you can access the result in "your" copy of the NativeArray
float aPlusB = result[0];
// Free the memory allocated by the result array
result.Dispose();
2018–06–15 Page published
C# Job System exposed in 2018.1 NewIn20181