Multithreading in a console application in C#?

0 like 0 dislike
3 views
Need to do the following (gruberova):


console application produces different actions in an infinite loop. It took a string input from the user. If you just put Console.ReadLine(), we get an interruption of the cycle and waiting for input.


Had the idea to take user input in another thread. revered Doku made in another thread. in the generated stream Console.ReadLine() does not work.


I understand the fact that ReadLine and WriteLine in fact use stdin and stdout, and they're on the main application thread?


If so, tell me how it is possible to realize the data input from the user without causing the waiting for input (the main program needs to run without stopping).
by | 3 views

4 Answers

0 like 0 dislike
Example call Console.WriteLine() from several threads — the canonical example, vstrechalis on the Internet on every corner, as an illustration of multithreading. Therefore, the idea of blocking stdin and stdout is wrong.
\r
On the other hand, perhaps ReadLine behaves differently. I agree with the previous comment — you need to make an infinite loop in a thread, and interactively work mostly.
by
0 like 0 dislike
To make the program logic in a separate thread, but mostly to work interactively...
by
0 like 0 dislike
Delegates and invoke to help You, in fact You have the app with the "interface".
by
0 like 0 dislike
thank you very much for the help
by

Related questions

0 like 0 dislike
4 answers
0 like 0 dislike
4 answers
0 like 0 dislike
4 answers
0 like 0 dislike
4 answers
0 like 0 dislike
2 answers
110,608 questions
257,186 answers
0 comments
28,757 users