Reputation: 11
I am currently writing a console game in C#. I am using two theads, both of which print something on the console with Console.SetCursorPosition(). But because the cursor is just one, the program sometimes swaps the places the text is printed and causes a mess. Is there a way to get around this?
Upvotes: 0
Views: 279
Reputation: 50170
sounds like you need a lock around the setposition and the write
lock(x)
{
Console.SetCursorPosition()
Console.Write();
}
where x is an object allocated for this purpose. It must be shared amongst all the threads
Upvotes: 3