CreateEvent()
Creates a synchronization event for tracking asynchronous operations.
Read time 1 minuteLast updated 7 days ago
Definition
- Type: Method
- Namespace: UnityEngine.LightTransport
- Assembly: UnityEngine.CoreModule
EventID CreateEvent()
Returns
Type | Description |
|---|---|
| EventID | Unique identifier for the newly created event. |
Remarks
Events provide a mechanism to track the completion status of asynchronous operations such as IDeviceContext.ReadBuffer and IDeviceContext.WriteBuffer. Each event can be used only once. After being passed to a read or write operation, it cannot be reused.
Use IDeviceContext.Wait to block until an event completes, or IDeviceContext.IsCompleted to check completion status without blocking.
Important: Events are single-use and must be destroyed with IDeviceContext.DestroyEvent after use to prevent resource leaks.
Examples
// Create an event to track a write operationvar writeEvent = context.CreateEvent();context.WriteBuffer(bufferSlice, inputData, writeEvent);// Check if the operation completedif (context.IsCompleted(writeEvent)){ Console.WriteLine("Write operation completed"); context.DestroyEvent(writeEvent);}