Make ReadStandardInput thread-safe
```ReadStandardInput``` was one of the thorniest areas of the interactive window because it not only could but needed to be called on a non-UI thread (so it could block waiting for user input). (In hindsight, it should probably have been task-returning, but the interface is frozen now. I hope to introduce an async version in a subsequent change.) The biggest change was moving the cleanup code - which tried to guess what had happened to the standard input session - to the individual methods that terminate the session - clear, reset, and submit. Now we don't have to guess about what state the UI thread will be in when we regain access. Based on a suggestion from @tmat, I also eliminated the previous-state mechanism in favor of encoding the information in the state itself. The complexity is basically the same, but this way we can have an explicit state machine (i.e. we don't have to consider the previous-state variable before making a state transition). There are still a few rough edges: https://github.com/dotnet/roslyn/issues/4879 https://github.com/dotnet/roslyn/issues/4878 Since our host doesn't currently support reading standard input, I tested the code manually using PTVS.
Showing
想要评论请 注册 或 登录