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() { // using async lock using (await _lock.LockAsync()) { if (_connection != null && _connection.CheckState()) { return; } _connection = new GrpcConnection(GetServer(_connection?.Server)); await _connection.ConnectAsync(); } }