c# - How do I force user to input after certain time? -


i force whatever user has typed entered after time. i've been using this, has problems.

string input = console.readline();  while (repeat == true) { if (time has passed) {     sendkeys.send("{enter}");     repeat = false; }  else     repeat = true; } 

the problem stays @ readline until user presses enter. don't want use readkey, because able contain more 1 character.

i'd use task , wait 5 seconds.

    static void main(string[] args)     {         list<consolekeyinfo> userinput = new list<consolekeyinfo>();         var userinputtask = task.run(() =>             {                 while (true)                     userinput.add(console.readkey(true));             });          userinputtask.wait(5000);         string userinputstr = new string(userinput.select(p => p.keychar).toarray());         console.writeline("time's up: pressed '{0}'", userinputstr);         console.readline();     } 

Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -