我有以下方法
public async Task<bool> Connect()
{
lock (_connectingLock)
{
if (_connecting)
throw new IOException("Already connecting");
_connecting = true;
}
try {
await tcpClient.ConnectAsync(...);
}
catch (SocketException e)
{
return false;
}
finally
{
lock (_connectingLock)
{
_connecting = false;
}
}
}
现在,我希望连续调用会Connect()
抛出 IOException,但它不会发生!
可能是什么原因?