C # Task Sequence Manager for Unity3D

Note: This question should have been written at https://gamedev.stackexchange.com/ as it relates to Unity3D development (nothing to do with C # Unity Framework)

I need a simple (single-threaded) library that allows you to run sequences of asynchronous tasks that can last for a period of time (usually using yield).

in actionscript I used http://www.dpdk.nl/opensource/running-tasks-in-order-with-a-task-based-sequence-manager which was a great task sequencer.

Is there something like this in C #?

NB: while the system.threading.task class seemed like a good solution initially, Unity 3.5 does not support the .net framework 4. The version I can use is 3.5. Are there alternatives?

+3


source to share


2 answers


I ended up creating my own system, which I wrote about here: http://www.sebaslab.com/svelto-taskrunner-run-serial-and-parallel-asynchronous-tasks-in-unity3d/



+3


source


You want to take a look at the parallel task library . This library can be used for multithreading or not, so it is quite reliable. This is actually what the next version of .NET is built on async/await

. I'll write a code snippet shortly.

var task = Task.Factory.StartNew<String>(
               ()=>
               {
                   //Do some long running task
                   return "Here are my results from part 1";
               })
           .ContinueWith<Int32>(
               (previousTask)=>
               {
                   var previousResult = previousTask.Result;
                   //Do some other long running task using the previous result
                   return 1;
               }); 

      



There is a lot that you can do with TPL. This is just a general idea.

There is also yield for iterators, but this is not necessarily asynchronous.

+4


source







All Articles