views:

292

answers:

4

Hello,

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 implementing this in Java, I suppose I might add a new task to an Executor for each line in the file or task per X lines (i.e. chunks).

For .Net, which is what I am using, I'm not so sure. I have a suspicion maybe CCR might be appropriate here, but I'm not familiar enough with it, which is why I pose this question.

Can CCR function in an equivalent fashion to Java Executors, or is there something else available?

Thanks

A: 

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.

sukru
Java's Executor can do much more than that. See http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ThreadPoolExecutor.html for example.
eed3si9n
+2  A: 

You may want to look at the Task Parallel Library.

Matt Brunell
A: 

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.

eed3si9n
+2  A: 

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.

Joel Mueller