EventDataBatch.TryAdd(EventData) Method

Definition

Attempts to add an event to the batch, ensuring that the size of the batch does not exceed its maximum.

public bool TryAdd (Azure.Messaging.EventHubs.EventData eventData);
member this.TryAdd : Azure.Messaging.EventHubs.EventData -> bool
Public Function TryAdd (eventData As EventData) As Boolean

Parameters

eventData
EventData

The event to attempt to add to the batch.

Returns

Boolean

true if the event was added; otherwise, false.

Exceptions

When a batch is published, it will be locked for the duration of that operation. During this time, no events may be added to the batch. Calling TryAdd while the batch is being published will result in an InvalidOperationException until publishing has completed.

Occurs when the eventData has a member in its Properties collection that is an unsupported type for serialization. See the Properties remarks for details.

Remarks

When an event is accepted into the batch, changes made to its properties will not be reflected in the batch nor will any state transitions be reflected to the original instance.

Note: Any ReadOnlyMemory<T>, byte array, or BinaryData instance associated with the event is referenced by the batch and must remain valid and unchanged until the batch is disposed.

Applies to