How to add a Timeout to Console.ReadLine()?

后端 未结 30 3094
耶瑟儿~
耶瑟儿~ 2020-11-22 04:57

I have a console app in which I want to give the user x seconds to respond to the prompt. If no input is made after a certain period of time, program logic should

30条回答
  •  南旧
    南旧 (楼主)
    2020-11-22 05:40

    I think you will need to make a secondary thread and poll for a key on the console. I know of no built in way to accomplish this.

提交回复
热议问题