msbyuva
msbyuva

Reputation: 3615

how to close console window automatically after console.readline() in C#

I have a console application which does some process and shows some success and failure messages at the end with Console.Readline();

Once the user see those messages, lets say in 10 seconds I want to close the console window automatically but that does not happen.

I tried return, Environemnt.Exit(0) but console does not close.

I don't the use to press some key, is there any way to close the console window automatically.

It's a .NET 4.0 based console application

Upvotes: 0

Views: 1191

Answers (1)

J.Wells
J.Wells

Reputation: 1759

Calling Thread.Sleep(10000); will delay execution of the current thread for 10 seconds, then continue, eliminating the need to call Console.Readline().

Upvotes: 1

Related Questions