Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Text/Cursor Positioning in Console

Tags:

c#

console

Time Display Problem

Any of you guys suggest how could i display the time just on top of the [x] Exit ? I'm currently using Console.Write() and ch.gotoxy() which sets my cursor into different places

(btw, my cursor is 'Ö' beside 293)

like image 379
Reinan Contawi Avatar asked Nov 05 '22 18:11

Reinan Contawi


2 Answers

I haven't tried but, what about creating a different Thread (or Task in the new TPL) that only writes the time? You'll need to share your cursor position between the two Threads and use some locking system while using Console.SetCursorPosition.

like image 200
spakinz Avatar answered Nov 10 '22 04:11

spakinz


There is an int under Console called CursorLeft and CursorTop. CursorLeft is your X coordinates and CursorTop is your Y. Just use that to set your position

like image 34
Grunt Avatar answered Nov 10 '22 05:11

Grunt