ConnectionWrapper

Ecng.Net.ConnectionStateTracker

Wraps an IConnection instance to listen for its state changes.

Inherits: Disposable

Constructors

ConnectionWrapper
public ConnectionWrapper(IConnection connection, Func<CancellationToken, ValueTask> stateChanged)
connectionWrapper = ConnectionWrapper(connection, stateChanged)

Initializes a new instance of the ConnectionWrapper class.

connection
The connection to wrap.
stateChanged
Callback invoked when the connection state changes.

Properties

State
public ConnectionStates State { get; private set; }
value = connectionWrapper.State
connectionWrapper.State = value

Gets the current connection state of the wrapped connection.

Methods

DisposeManaged
protected override void DisposeManaged()
connectionWrapper.DisposeManaged()

Disposes the managed resources.

OnStateChanged
private ValueTask OnStateChanged(ConnectionStates newState, CancellationToken cancellationToken)
result = connectionWrapper.OnStateChanged(newState, cancellationToken)

Handles the state change event from the wrapped connection.