I am new to programming, but I have a question:
How can I show a different output from a task (I have to use tasks) on different lines in the console? In addition, I want to rewrite the lines every time, so the output should show:
i // overwrite this line every time.
j // overwrite this line every time.
I tried using SetCursorPosition, but it causes a collision between the task that occurs after that.
Example of a mini-code (I hope this becomes clear):
Task a = Task.Run(() =>
{
int i;
for (i = 0; i <= 1000000; i++)
{
Console.SetCursorPosition(Console.CursorLeft, 0); // ?
Console.WriteLine("{0}", i);
}
});
Task b = Task.Run(() =>
{
int j;
for (j = 0; j <= 1000000; j++)
{
Console.SetCursorPosition(Console.CursorLeft, 3); // ?
Console.WriteLine("{0}",j);
}
});
Console.ReadLine();
Thanks in advance:)
source
share