Prevent Job Execution / Iteration

Hey guys!

So this time, it would be nice if I could prevent the execution of a job or to stop the current iteration.

how do I achieve that?

        var arrayHandle = Job.WithCode(() =>
        {
            array = queue.ToArray(Allocator.TempJob);
            if (array.Length == 0)
            {
                // prevent next Job here
            }
        }).Schedule(queueHandle);

        Entities.ForEach((in Entity entity, in UnassignedGravity gravity, in Translation translation) =>
        {
            if (array.Length == 0)
            {
                //end iteration here
            }
        // rest of code
        }).ScheduleParallel(arrayHandle);

@dCalle this should do the trick.

        var arrayHandle = Job.WithCode(() =>
        {
            array = queue.ToArray(Allocator.TempJob);
            if (array.Length == 0)
            {
                return;
            }
        }).Schedule(queueHandle);
        Entities.ForEach((in Entity entity, in UnassignedGravity gravity, in Translation translation) =>
        {
            if (array.Length == 0)
            {
                return;
            }
        // rest of code
        }).ScheduleParallel(arrayHandle);
1 Like

thanks man, I just figured, I can simply use an if statement before the second foreach. (Of course I have to use Run()) and if I use its handle just check if its null… Weird stuff, not the best one could wish for… but obviously, I dabble^^