-1

I'm new to the Microsoft Concurrency Runtime (and asynchronous programming in general), and I'm trying to understand what can and can't be done with it. Is it possible to create a task group such that the tasks execute in the order in which they were added, and any task doesn't start until the previous one ends?

I'm trying to understand if there's a more general and devolved way of dealing with tasks compared to chaining several tasks within a single member function. For example, let's say I have a program that creates resources at different points in a program, and the order in which the resources are allocated matters. Could any resource allocation function that was called simply append a task to the end of a central task list, with the result that the tasks execute in the order in which they were added (i.e. the order in which the resource allocation functions were called)?

Thanks,

RobertF

RobertF
  • 1
  • 2
  • What is your actual question? It is not clear what you are asking. – Dave Hillier Jul 01 '12 at 19:32
  • I may be wrong, but my understanding of task groups (the Concurrency::task_group class) was that the tasks executed independently of each other, e.g. the fifth task added might finish before the first one that was added. I was trying to find out if there was a way to ensure that the nth task wouldn't start before the (n-1)th had finished. – RobertF Jul 01 '12 at 23:10
  • Do you want to serialize "tasks"? Why not just use some single threaded code? – Dave Hillier Jul 01 '12 at 23:18
  • What you're describing sounds like a pipeline - I'd look into an agent/actor pattern; check out the Asynchronous Agents Library which is built on top of PPL: http://msdn.microsoft.com/en-us/library/dd492627. – Andy Rich Jul 23 '12 at 22:49

1 Answers1

0

I'm not sure I understand what you're trying to achieve, but, are you looking for Agent or Actor model?

You post messages to an Async Agent and it processes them. It can then send messages to other agents.

Dave Hillier
  • 18,105
  • 9
  • 43
  • 87