# IAsyncObserver&lt;T&gt; Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.streams.iasyncobserver-1/)

## OnCompletedAsync {#oncompletedasync-20fd43e6}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.streams.iasyncobserver-1/methods/oncompletedasync-20fd43e6/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Streaming/Core/IAsyncObserver.cs#L47)

```csharp
public virtual Task OnCompletedAsync()
```

Notifies the consumer that the stream was completed. 

The Task returned from this method should be completed when the consumer is done processing the stream closure.

### Returns

A Task that is completed when the stream-complete operation has been accepted.

## OnErrorAsync(Exception) {#onerrorasync-system-exception-c3c980e8}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.streams.iasyncobserver-1/methods/onerrorasync-system-exception-c3c980e8/)

```csharp
public abstract Task OnErrorAsync(Exception ex)
```

Notifies the consumer that the stream had an error. 

The Task returned from this method should be completed when the consumer is done processing the stream closure.

### Parameters

- `ex` (`Exception`): An Exception that describes the error that occurred on the stream.

### Returns

A Task that is completed when the close has been accepted.

## OnNextAsync(T, StreamSequenceToken?) {#onnextasync-t-orleans-streams-streamsequencetoken-nullable-45b9c0cc}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.streams.iasyncobserver-1/methods/onnextasync-t-orleans-streams-streamsequencetoken-nullable-45b9c0cc/)

```csharp
public abstract Task OnNextAsync(T item, StreamSequenceToken? token = null)
```

Passes the next item to the consumer. 

The Task returned from this method should be completed when the item's processing has been sufficiently processed by the consumer to meet any behavioral guarantees.

When the consumer is the (producer endpoint of) a stream, the Task is completed when the stream implementation has accepted responsibility for the item and is assured of meeting its delivery guarantees. For instance, a stream based on a durable queue would complete the Task when the item has been durably saved. A stream that provides best-effort at most once delivery would return a Task that is already complete.

When the producer is the (consumer endpoint of) a stream, the Task should be completed by the consumer code when it has accepted responsibility for the item. In particular, if the stream provider guarantees at-least-once delivery, then the item should not be considered delivered until the Task returned by the consumer has been completed.

### Parameters

- `item` (`T`): The item to be passed.
- `token` (`StreamSequenceToken?`): The stream sequence token of this item.

### Returns

A Task that is completed when the item has been accepted.
