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.

Remarks

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

Applies to