none
Task, Thread - way to make it more manageable RRS feed

  • Question

  • 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?

    t3

    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

    Wednesday, March 13, 2019 5:49 PM

Answers

All replies