Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class JobExample : MonoBehaviour
- {
- public int JobCount = 10;
- public bool ParallelExecution;
- void Update ()
- {
- var handles = new JobHandle[JobCount];
- for (int i = 0; i < JobCount; i++)
- {
- DummyJob job = new DummyJob();
- handles[i] = job.Schedule();
- if (!ParallelExecution)
- {
- handles[i].Complete();
- }
- }
- if (ParallelExecution)
- {
- for (int i = 0; i < JobCount; i++)
- {
- handles[i].Complete();
- }
- }
- }
- }
- public struct DummyJob : IJob
- {
- public void Execute()
- {
- Thread.Sleep(10);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment