Console.ReadKey

This is a discussion on Console.ReadKey within the C# Programming forums, part of the General Programming Boards category; Hello everyone, I can not find answer from MSDN. My question is, when Console.ReadKey is called on a thread, 1. ...

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    1,579

    Console.ReadKey

    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

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    Calling Sleep on a thread will not consume CPU time. That's the whole point.

    The thread will block. A blocked thread should not consume CPU. Test it.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21