public async Task ConnectAsync() { // using async lock using (await _lock.LockAsync()) { if (_connection != null && _connection.CheckState()) { return; } _connection = new GrpcConnection(GetServer(_connection?.Server)); await _connection.ConnectAsync(); } }
public async Task ConnectAsync(TimeSpan timeout) { // using async lock using (await _lock.LockAsync()) { if (_connection != null && _connection.CheckState()) { return; } if (_connection != null && !_connection.CheckState()) { await _connection.ShutdowmAsync(); } _connection = new GrpcConnection(GetServer(_connection?.Server)); await _connection.ConnectAsync(timeout); } }
public async Task ConnectAsync(TimeSpan timeout) { // using async lock using (await _lock.LockAsync()) { if (_connection != null && _connection.CheckState()) { return; } if (_connection != null && !_connection.CheckState()) { await _connection.ShutdowmAsync(); } var metadata = GetServerMetadata(_connection?.Server); _connection = new GrpcConnection(metadata.Address, metadata.CertificatePath, metadata.Token); await _connection.ConnectAsync(timeout); } }