ShellStream.EndExpect continues to wait for a match until the timeout is reached
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 4.4k
- Forks
- 993
- Avg merge
- 9d 21h
- Merged PRs (30d)
- 1
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing ShellStream.BeginExpect and EndExpect to understand how the expect operation and AsyncResult are completed. Define the cancellation behavior so an expect can stop promptly without completing the result twice, then add coverage for cancellation and the existing timeout or match paths. Done means cancellation returns promptly and the background expect work exits cleanly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- networking
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100