Writing to BufferElement components from a parallel foreach lambda job

I’ve been using ForEach in a JobComponentSystem with a lambda as it seemed like that was the latest and greatest way of doing things, but I’m a little stuck trying to write to a BufferElement.

This is the only system that ever writes to the buffer (or reads from it for that matter), and each entity’s buffer is independent of every other entity, so it should be fine writing to them in parallel from my entities.foreach, but it comes up with the warning. I’ve come across NativeDisableParallelForRestriction, but that only seems to help when I’m writing an IJobForEach, or if I downgrade to not-parallel. Are they my only options, or is there a way to specify that I know it’s safe in the lambda format?

ForEach + SystemBase is latest :slight_smile:
For Entities.ForEach you can use WithNativeDisableParallelForRestriction with same result as [WithNativeDisableParallelForRestriction] for IJobForEach fields (btw IJobForEach deprecated, use SystemBase with Entities.ForEach, or IJobChunk or manual chunk iteration or Job.WithCode instead)