Jeff Morris
added a comment - 18/May/17 6:44 PM - edited The problem appears to be that when the SslConnection was rewritten some time back to call the async methods asynchronously, a subtle bug was introduced:
The IOService calls connection.Send
connection.Send calls connection.SendAsync synchronously
connection.SendAsync returns the connection back to the queue (it was designed to be a fire and forget method since it can finish on any thread)
SendAsync returns back to Send
Send returns back to IOService
IOService returns the connection back the queue - it has now been enqueued twice (once in SendAsync and once here)
Next threads call IOService and dequeue connection with two references in the queue - each use SslStream simultaneously and the NotSupportedException is thrown.