Is there a .Net equivalent to java.util.concurrent.Executor?

后端 未结 5 2247
轻奢々
轻奢々 2021-02-20 01:35

Have a long running set of discrete tasks: parsing 10s of thousands of lines from a text file, hydrating into objects, manipulating, and persisting.

If I were implement

相关标签:
5条回答
  • 2021-02-20 01:59

    Maybe this is related: Design: Task Parallel Library explored. See 10-4 Episode 6: Parallel Extensions as a quick intro.

    For older thread-based approach, there's ThreadPool for pooling.

    0 讨论(0)
  • 2021-02-20 02:03

    You may want to look at the Task Parallel Library.

    As of C# 5 this is built into the language using the async and await keywords.

    0 讨论(0)
  • 2021-02-20 02:04

    The BackgroundWorker class is probably what you're looking for. As the name implies, it allows you to run background tasks, with automatically managed pooling, and status update events.

    0 讨论(0)
  • 2021-02-20 02:04

    For anyone looking for a more contemporary solution (as I was), check out the EventLoopScheduler class.

    0 讨论(0)
  • 2021-02-20 02:06

    If you're going to ask a bunch of .NET people what's closest to being equivalent to Java Excecutors, it might not hurt to describe the distinguishing features of Java Executors. The person who knows your answer may not be any more familiar with Java than you are with .NET.

    That said, if the already-mentioned Task Parallel Library is overkill for your needs, or you don't want to wait for .NET 4.0, perhaps ThreadPool.QueueUserWorkItem() would be what you're looking for.

    0 讨论(0)
提交回复
热议问题