Cinchoo – Read from console with timeout

You have a console application in which you want to give the user number of seconds to respond to the prompt. If no input is made after a certain period of time, program should continue.

Cinchoo framework provides this through ChoConsole class.

1. Add reference to Cinchoo.Core.dll assembly

2. Namespace Cinchoo.Core.Shell.Console

Below are the following methods

Read() Overloads:

This method reads the next character from the standard input stream either within the specified timeout period or infinity.

public static int Read(int timeoutInMilliSeconds);
public static int Read(int timeoutInMilliSeconds, int? defaultValue);
public static int Read(int timeoutInMilliSeconds, int? defaultValue, string errMsg)

ReadLine() Overloads:

This method reads the next line of characters from the standard input stream either within the specified timeout period or infinity.

public static int ReadLine(int timeoutInMilliSeconds);
public static int ReadLine(int timeoutInMilliSeconds, int? defaultValue);
public static int ReadLine(int timeoutInMilliSeconds, int? defaultValue, string errMsg)

ReadKey() Overloads:

This method reads the next character from the standard input stream either within the specified timeout period or infinity.

public static ConsoleKeyInfo ReadKey(int timeoutInMilliSeconds);
public static ConsoleKeyInfo ReadKey(int timeoutInMilliSeconds, int? defaultValue);
public static ConsoleKeyInfo ReadKey(int timeoutInMilliSeconds, int? defaultValue, string errMsg)
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s