As the console runs in the Main method, which in turn is a static method, I believe the output is to use another Thread.
In the code below, I create a Thread "t" that will wait 10 seconds, and then clears the console.
After Thread is created, it follows normal system processing.
class Program
{
static int loop = 0;
static void Main(string[] args)
{
bool aplicacaoRodando = true;
Thread t = new Thread(()=>{
while (aplicacaoRodando)
{
Thread.Sleep(10000);
Console.Clear();
loop = 0;
}
});
t.Start();
while (aplicacaoRodando)
{
Thread.Sleep(1000);
loop++;
Console.WriteLine("Tá rodando a aplicação..." + loop);
}
}
}
ps. I put the range of 10,000 ms only to exemplify and make the test faster. Just change the Thread.Sleep(10000);
for the desired range.
Which
timer
is that it? Something else, usually, timer has to be fired, maybe it’s missing atimer.Start()
– Felipe Avelar
Threading, does not contain timer.start ;/
– user92401
Any reason to be of Threading lib? It could not be itself System timer?
– Felipe Avelar
I use some thread.Sleep in the class
– user92401