tonerdo / readline

A Pure C# GNU-Readline like library for .NET/.NET Core
MIT License
810 stars 77 forks source link

Add ReadAsync with CancellationToken #46

Closed Astaelan closed 6 years ago

Astaelan commented 6 years ago

Add function to ReadLine static class with following signature: public static async Task<string> ReadAsync(CancellationToken)

Implement by using Console.In.ReadAsync.

This makes it possible to interrupt input with Control-C, using the CancellationToken before a line is received.

Latency commented 6 years ago

@Astaelan ,

Your idea is becoming very platform specific and is a far derivative from the POSIX based ReadLine that this project was conceived from.

Once again, you are toying around with feature requests and constructs directed towards signatures found in the mscorlib.dll

You are more than welcome to create a derived class from the library and intercept the 'Console' methods in question. Perhaps, look at AOP techniques similarly.

This project does not make use of the async calls found within, hence would require the thread scheduling and sync / non-blocking for 'Console2' > STDOUT calls being utilized.

You are more than welcome to create a PR and add the async calls yourself, as their are about 20-30+ overloads found just for WriteLine. Thus, would require revamping the 'Console2' wrapper class which would essentially make your IConsole a mirror/sub-set of the original Console class found from mscorlib.dll as well.

Astaelan commented 6 years ago

Author isn't interested.