To schedule a job in the main thread, you must:
Schedule puts the job into the job queue for execution at the appropriate time. Once scheduled, you cannot interrupt a job.
Note: You can only call
Schedule from the main thread.
// 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; // Free the memory allocated by the result array result.Dispose();
2018–06–15 Page published with editorial review
C# Job System exposed in 2018.1 NewIn20181
Did you find this page useful? Please give it a rating: