App hangs for 20 secs on exit after TcpClient BeginConnect
问题 I have problem with strange behavior of TcpClient.BeginConnect() and TcpClient.EndConnect() methods. I use BeginConnect() to add timeout to Connect() method (see extension method code below). If I get connected I call EndConnect() and every thing is ok, but If I get timeout I can't call EndConnect() because it will block for about 20 seconds, so I just call this non-blocking code: result.AsyncWaitHandle.Close(); result.AsyncWaitHandle.Dispose(); client.Close(); Problem is when I close the