Hello everyone,
I can not find answer from MSDN. My question is, when Console.ReadKey is called on a thread,
1. the thread will be still in running status (like we call Sleep), which will consume CPU time?
2. or the thread will be in wait status like we call WaitOne, and keyboard press will signal the event?
thanks in advance,
George
Fernando SotoPosted Jun 12, 2008, 1:46 PM
George GeorgePosted Jun 12, 2008, 8:17 AM
Thanks Fernando!
Question answered.
regards,
George
Fernando SotoPosted Jun 12, 2008, 8:13 AM
Hi George;
From the Micrfosoft documentation located at :
http://msdn.microsoft.com/en-us/library/x3h8xffw(VS.80).aspx
"The ReadKey method waits, that is, blocks on the thread issuing the ReadKey method, until a character or function key is pressed. A character or function key can be pressed in combination with one or more ALT, CTRL, or SHIFT modifier keys. However, pressing a modifier key by itself will not cause the ReadKey method to return."
The theead calling the ReadKey method is placed in a wait state, thread is not executing any code while it the wait state, until a key is pressed on the keyboard.
Fernando