Task, Thread - way to make it more manageable

  • Thread starter Thread starter Markus Freitag
  • Start date Start date
M

Markus Freitag

Guest
Hello!
How can I outsource that to a function,
to make it more manageable?
For stop, I think with Canceltoken, right?
For suspend, ManualResetEvent, right?

1414840.jpg

Maybe this way?
Task track01 = Task.Run(() =>
{
Task1();
//while (true)
//{
// Lane1.Step1();
// Lane1.Step2();
// Lane1.Step3();
// Thread.Sleep(2000);
//}
});
public void Task1()
{
while (true)
{
Lane1.Step1();
Lane1.Step2();
Lane1.Step3();
Thread.Sleep(2000);
}
}


What is better thread or task today, what is more correct today?
The loop gets bigger, then a function name would be better.
Thanks in advance.
Greetings Markus

Continue reading...
 
Back
Top