C
C#11mo ago
Rainys

❔ is there an asynchronous Console.ReadLine() replacement?

hey, so i'm making a console application and main problem i'm running into is, because it's an application for a server, whenever i start writing something (i have a check that stops ReadLine if there's no letters typed in) the server gets timed out, because i have to call an update function on it every tic, so what i have currently is far from ideal, and i've looked into it and Console.ReadLine() is a synchronous function, which means it stops everything until it gets the "enter" key pressed, and i want the application to keep running in the background. Oh and honestly i wouldn't mind that much making my own system for that based on key presses if it means it's asynchronous.
7 Replies
ero
ero11mo ago
Console.Out.WriteLineAsync, but i've heard that you should not use async with console stuff
Rainys
Rainys11mo ago
doesn't that write a line? i want it to read lines, basically what Console.ReadLine() does perfectly, but asynchronous
ero
ero11mo ago
so use Console.In.ReadLineAsync...
Rainys
Rainys11mo ago
alright
sibber
sibber11mo ago
what does console application for a server mean
Rainys
Rainys11mo ago
basically just a console app (you can use Console.WriteLine() and Console.ReadLine()) for a video game server i'm making, i use a library which does all the heavy lifting so i only do stuff like check if someone types in port then i switch the port etc.
Accord
Accord11mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.