<PackageReference Include="Grpc.Net.Client" Version="2.70.0" />

Grpc.Net.Client.GrpcChannel

public sealed class GrpcChannel : ChannelBase, IDisposable
Represents a gRPC channel. Channels are an abstraction of long-lived connections to remote servers. Client objects can reuse the same channel. Creating a channel is an expensive operation compared to invoking a remote call so in general you should reuse a single channel for as many calls as possible.
public ConnectivityState State { get; }

Gets current connectivity state of this channel. After the channel has been shutdown, Shutdown is returned.

This API is only supported when the channel is configured with a SocketsHttpHandler HTTP transport.

Note: Experimental API that can change or be removed without any prior notice.

public static GrpcChannel ForAddress(string address)

Creates a GrpcChannel for the specified address.

public static GrpcChannel ForAddress(string address, GrpcChannelOptions channelOptions)

Creates a GrpcChannel for the specified address and configuration options.

public static GrpcChannel ForAddress(Uri address)

Creates a GrpcChannel for the specified address.

public static GrpcChannel ForAddress(Uri address, GrpcChannelOptions channelOptions)

Creates a GrpcChannel for the specified address and configuration options.

public Task ConnectAsync(CancellationToken cancellationToken = default)

Allows explicitly requesting channel to connect without starting an RPC. Returned task completes once State Ready was seen. There is no need to call this explicitly unless your use case requires that. Starting an RPC on a new channel will request connection implicitly.

This API is only supported when the channel is configured with a SocketsHttpHandler HTTP transport.

Note: Experimental API that can change or be removed without any prior notice.

public void Dispose()

Releases the resources used by the GrpcChannel class. Clients created with the channel can't be used after the channel is disposed.

public Task WaitForStateChangedAsync(ConnectivityState lastObservedState, CancellationToken cancellationToken = default)

Wait for channel's state to change. The task completes when State becomes different from lastObservedState.

This API is only supported when the channel is configured with a SocketsHttpHandler HTTP transport.

Note: Experimental API that can change or be removed without any prior notice.