locked
Task.Run RRS feed

  • Question

  • User1453549677 posted
    I copied this Task example from the web and it gives a compiler error on Task.Run (Task does not contain a definiton for 'Run')

    using
    System; using System.Threading; using System.Threading.Tasks; public class Example { public static void Main() { ShowThreadInfo("Application"); var t = Task.Run(() => ShowThreadInfo("Task") ); t.Wait(); } static void ShowThreadInfo(String s) { Console.WriteLine("{0} Thread ID: {1}", s, Thread.CurrentThread.ManagedThreadId); } }
    Friday, February 16, 2018 8:46 PM

Answers

  • User409696431 posted

    What framework version are you targeting?  You'll need 4 or above.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, February 16, 2018 9:54 PM

All replies

  • User409696431 posted

    What framework version are you targeting?  You'll need 4 or above.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, February 16, 2018 9:54 PM
  • User1453549677 posted

    Thanks!

    Friday, February 16, 2018 10:48 PM