IConnection

Ecng.Net

Defines an asynchronous contract for a connection that can be established and disconnected.

Methods

ConnectAsync
public ValueTask ConnectAsync(CancellationToken cancellationToken)
result = iConnection.ConnectAsync(cancellationToken)

Asynchronously connects to a target.

cancellationToken
A token to monitor for cancellation requests.

Returns: A task representing the asynchronous operation.

DisconnectAsync
public ValueTask DisconnectAsync(CancellationToken cancellationToken)
result = iConnection.DisconnectAsync(cancellationToken)

Asynchronously disconnects the current connection.

cancellationToken
A token to monitor for cancellation requests.

Returns: A task representing the asynchronous operation.

Events

StateChanged
public event Func<ConnectionStates, CancellationToken, ValueTask> StateChanged
iConnection.StateChanged += handler

Occurs when the connection state has changed.