none
Ways of writing, call options Task RRS feed

  • Question

  • Hello,
    Is there an overview of the possibilities.
    How can I call the task?

    /// ## works not. I want a own function.
    Like this.

    public delegate void MyDelegate(string t1);
    public void Test4()
    {
     var mytask = new Task(delegate () { Console.WriteLine("Anonym methode 1 !"); });
     mytask.Start();
    }
    public void Test5()
    {
     // Action is a void
     var mytask = new Task(() => { Console.WriteLine("Anonym methode 2 !"); });
     mytask.Start();
    }
    public void Test6()
    {
     MyDelegate testDelegate = new MyDelegate(Test10);
     // Action is a void
     var mytask = new Task(testDelegate); // as Action);  /// ## works not
     mytask.Start();
    }
    public void Test10(string t1)
    {
     Console.WriteLine($"Possibility 3 - {t1}"); 
    }


    With best regards Markus


    Tuesday, March 27, 2018 4:31 PM

Answers