locked
The Task Class RRS feed

  • Question

  • Please let someone help me. Under which namespace is the Task class that has Run() as a method?  I used the Task class Under the Systems.Threading.Tasks namespace and the intellisense showed that the Task class has no method called Run(). Below is the illustration of what I did:

    using Systems;

    using Systems.Threading.Tasks;

    namespace MyNamespace{

    class MyClass{

           public static void main(){

         Task t = Task.Run(() =>{

    //codes here

    });

    }

    }

    }

    Wednesday, March 16, 2016 4:07 PM

Answers

  • System.Threading.Task is the correct namespace.

    Although I see you have an extra 's' wherever you have the word System.

    (Its System and System.Threading.Task, not Systems or Systems.Threading.Task).

    Otherwise your code works perfectly fine for me.

    • Proposed as answer by Kristin Xie Thursday, March 17, 2016 2:23 AM
    • Marked as answer by DotNet Wang Friday, March 25, 2016 12:55 AM
    Wednesday, March 16, 2016 4:11 PM