# AddJobHandleForProducer(JobHandle)

> Adds the specified JobHandle to this system's list of dependencies.

## Definition

* **Type:** Method
* **Namespace:** [Unity.Entities](/engine/7000.0/script-reference/unity/entities.md)
* **Assembly:** UnityEngine.EntitiesModule

```csharp
public void AddJobHandleForProducer(JobHandle producerJob)
```

### Parameters

**** (\[JobHandle]\(/engine/7000.0/script-reference/unity/jobs/jobhandle)): The JobHandle of a Job which this buffer system should wait for before playing back its pending command buffers.

### Remarks

When you write to an [EntityCommandBuffer](/engine/7000.0/script-reference/unity/entities/entitycommandbuffer.md) that you created with [EntityCommandBufferSystem.CreateCommandBuffer](/engine/7000.0/script-reference/unity/entities/entitycommandbuffersystem/createcommandbuffer.md) from a job, you must add the [JobHandle](/engine/7000.0/script-reference/unity/jobs/jobhandle.md) of that job to this [EntityCommandBufferSystem](/engine/7000.0/script-reference/unity/entities/entitycommandbuffersystem.md) input dependencies by calling this function. Otherwise, this system could attempt to execute the command buffer contents while the writing job is still running, causing a race condition.

Don't call this function for command buffers that you created through the buffer system's `Singleton` component. Those command buffers are tracked through the singleton component itself, and this system completes all jobs scheduled against that component before it plays the command buffers back.

The following example illustrates how to use one of the default [EntityCommandBufferSystem](/engine/7000.0/script-reference/unity/entities/entitycommandbuffersystem.md)s. The code selects all entities that have one custom component, in this case, `AsyncProcessInfo`, and processes each entity in the `Execute()` function of an [IJobEntity](/engine/7000.0/script-reference/unity/entities/ijobentity.md) Job. After processing, the Job uses a [EntityCommandBuffer](/engine/7000.0/script-reference/unity/entities/entitycommandbuffer.md) to remove the `ProcessInfo` component and add a `ProcessCompleteTag` component. Another system could use the `ProcessCompleteTag` to find entities that represent the end results of the process.
