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.
```
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.