How to set timeout - wiwanek/Expect.NET GitHub Wiki

Expected output may never be printed, we should be able to detect such case and handle it properly. Session class offers timeout mechanism. The timeout value is stored in Session.Timeout property. Timeout value is set in milliseconds.

Timer is started by execution of Session.Expect() or Session.ExpectAsync() method is called. If timer expires before expected output is received from session, System.TimeoutException is thrown.

The timeout value must be greater than zero. Default value is set to 2500 milliseconds.

Usage example:

Session session; // in real implementation session should be created here...
s.Timeout = 100;  // setting timeout to 100 milliseconds
try {
  session.Expect("expected output", s => Console.WriteLine(s)); // expecting some output....
} catch(System.TimeoutException e) {  
  Console.Error.WriteLine(e.Message); // exception handling...
}