Description
I am using the published stable Renci SSH.NET nuget package (2016.1.0)
I am successfully using ShellStreams BeginExpect method to wait asynchronously for one of several patterns to match until a timeout is reached. Additionally, I would like to be able to cancel the expect at any time arbitrarily.
I had hoped EndExpect would immediately stop the expect thread, but instead the behaviour appears to be that EndExpect blocks until a match is found.
I have tried setting the AsyncResult as completed using SetAsCompleted before calling EndExpect to bypass this behaviour, but the thread will continue to search for matches in the background until it eventually calls SetAsCompleted itself and throws an exception (InvalidOperationException - You can set a result only once).
I would like to propose a CancelExpect method that quickly sets the AsyncResult as cancelled and causes the expect thread to quickly exit.
I'm very happy to implement this feature myself, I would just like to know if there is already a better approach for what I am trying to do, and which branch I should be basing my work on.