Parallel code execution?

  • Thread starter Thread starter Pavils Jurjans
  • Start date Start date
P

Pavils Jurjans

Hello,

I asm looking for help on parallel code execution syntax in C#:

I am thinking about report generation engine, that needs to compile large
output document, which consists of multiple independent parts. I'd like to
initiate the building of these separate parts simultaneously, and have some
super-process that overlooks all the production and once the first part is
ready to go, spews it to the output, then if second part is not yet ready,
waits once it is, and outputs that, too, and so on and so forth until the
last part is done. I see some ways how this can be done without parallel
processing, but I want to try out my hand at parralel computing, and that
approach would also be more flexible and customizable.

Currently I dont quite have idea where to start. I imagine that the super
process must initiate the sub processes, and these subprocesses must start,
but return control to the super process while still processing. Then there
would be some events that sub processes are generating, something like
"contentReady", what could be heard by super process and properly handled.

Thanks for any insights,

Pavils
 
Pavils,

What you need to use is a multithreaded application. Look into the
Thread
class in the System.Threading namespace. The MSDN documentation has a
lot of information on this. You *could* could an async method to do the long
running work, but in the end the CLR will leverage threads (from the
ThreadPool) to do so.

HTH,

//Andreas
 
Back
Top