Can someone help to understand the advantage, if any, when using CreateAnonymousThread or Task?

Can someone help to understand the advantage, if any, when using CreateAnonymousThread or Task?
Can be my impression only, but Task seems to be slow?

Comments

  1. I'm not sure what your question is. You can create many Tasks, and a thread pool will execute them. If you create hundreds of threads, they'll run at the same time, competing for resources.

    ReplyDelete
  2. Tasks are not slow - but there is some overhead which can count if you only have very short running work for the tasks. But that is the same with threads.

    RuleOfThumb: Use a thread for long runners and tasks for the rest.

    ReplyDelete
  3. Oliver Münzberg "Use a thread for long runners and tasks for the rest."
    Thank you for the tip, gonna follow the rule.

    ReplyDelete

Post a Comment