ConnectionStateTracker
Ecng.Net
Tracks the connection states of multiple IConnection instances and aggregates their overall state.
Erbt von: Disposable
Implementiert: IConnection
Methoden
Add
public void Add(IConnection connection)
connectionStateTracker.Add(connection)
Adds a connection to be tracked.
- connection
- The connection to add.
ConnectAsync
public ValueTask ConnectAsync(CancellationToken cancellationToken)
result = connectionStateTracker.ConnectAsync(cancellationToken)
Connects all tracked connections asynchronously.
- cancellationToken
- A token to observe for cancellation.
Rückgabe: A task that represents the asynchronous connect operation.
DisconnectAsync
public ValueTask DisconnectAsync(CancellationToken cancellationToken)
result = connectionStateTracker.DisconnectAsync(cancellationToken)
Disconnects all tracked connections asynchronously.
- cancellationToken
- A token to observe for cancellation.
Rückgabe: A task that represents the asynchronous disconnect operation.
DisposeManaged
protected override void DisposeManaged()
connectionStateTracker.DisposeManaged()
Releases the managed resources used by the ConnectionStateTracker.
Remove
public bool Remove(IConnection connection)
result = connectionStateTracker.Remove(connection)
Removes a tracked connection.
- connection
- The connection to remove.
Rückgabe: True if the connection was successfully removed; otherwise, false.
UpdateOverallStateAsync
private ValueTask UpdateOverallStateAsync(CancellationToken cancellationToken)
result = connectionStateTracker.UpdateOverallStateAsync(cancellationToken)
Updates the overall state based on the states of all tracked connections.
Ereignisse
StateChanged
public event Func<ConnectionStates, CancellationToken, ValueTask> StateChanged
connectionStateTracker.StateChanged += handler
Occurs when the connection state has changed.