diff --git a/Nodejs/Product/Nodejs/Debugger/Communication/DebuggerConnection.cs b/Nodejs/Product/Nodejs/Debugger/Communication/DebuggerConnection.cs index 1130e425e..30d6cd5e8 100644 --- a/Nodejs/Product/Nodejs/Debugger/Communication/DebuggerConnection.cs +++ b/Nodejs/Product/Nodejs/Debugger/Communication/DebuggerConnection.cs @@ -36,7 +36,8 @@ sealed class DebuggerConnection : IDebuggerConnection { private readonly INetworkClientFactory _networkClientFactory; private INetworkClient _networkClient; private readonly object _networkClientLock = new object(); - private volatile Version _nodeVersion; + private volatile Version _nodeVersion; + private bool _isClosed = false; public DebuggerConnection(INetworkClientFactory networkClientFactory) { Utilities.ArgumentNotNull("networkClientFactory", networkClientFactory); @@ -51,8 +52,10 @@ public void Dispose() { /// /// Close connection. /// - public void Close() { - lock (_networkClientLock) { + public void Close() { + _isClosed = true; + + lock (_networkClientLock) { if (_networkClient != null) { _networkClient.Dispose(); _networkClient = null; @@ -119,7 +122,7 @@ public void Connect(Uri uri) { lock (_networkClientLock) { int connection_attempts = 0; const int MAX_ATTEMPTS = 5; - while (true) { + while (!_isClosed) { connection_attempts++; try { // TODO: This currently results in a call to the synchronous TcpClient