When running a multithreaded application, when both threads hit the SocketConnect method at the same time I get a "The system has detected an invalid pointer address when attempting to make a pointer call" error at the line:
```
var connectResult = this._socket.BeginConnect(ep, null, null);
```
when it hits the second time.
If I change this to:
```
this._socket.Connect(ep);
```
All threads execute without a problem.
This change also seems to resolve the "disconnect" issue. You can now freely connect and disconnect without having to create a new SFTPClient object.
I understand why we want to use the Async method of BeginConnect.... but I don't understand why the async call causes and error and the non-Async method doesn't.
Comments: ** Comment from web user: Crucial **
```
var connectResult = this._socket.BeginConnect(ep, null, null);
```
when it hits the second time.
If I change this to:
```
this._socket.Connect(ep);
```
All threads execute without a problem.
This change also seems to resolve the "disconnect" issue. You can now freely connect and disconnect without having to create a new SFTPClient object.
I understand why we want to use the Async method of BeginConnect.... but I don't understand why the async call causes and error and the non-Async method doesn't.
Comments: ** Comment from web user: Crucial **
Again... this problem only seems to occur while inside an HTTPS Proxy environment. When outside the proxy environment, the code executes as expected. I am unsure if the problem is caused by the library or by a problem within the DotNet framework seeing as the error is caused within the Socket object.