Skip to main content
deleted 11 characters in body
Source Link
War
  • 1.7k
  • 1
  • 18
  • 33

I took a similar approach here:

https://github.com/TehWardy/ccoder-Voxels/tree/master/Assets/Tasks

My code basically does what the .Net 4 tasks stuff does (well some of it) in that I pass a lambda in and get a task back ....

var task = Task.Factory.StartNew(() => { ... stuff you want to doreturn ...GenerateLotsOfData(); });

I then use update to handle when the task is complete ...

void update() {
  if(task.Complete) { ... do somethingvar withdata result= ..task.Result; }
}

Using my code I don't appear to get any locking problems.

The key difference I can see is that I limit the number of threads my tasking system can use, other than that it's pretty much the same approach.

I took a similar approach here:

https://github.com/TehWardy/ccoder-Voxels/tree/master/Assets/Tasks

My code basically does what the .Net 4 tasks stuff does (well some of it) in that I pass a lambda in and get a task back ....

var task = Task.Factory.StartNew(() => { ... stuff you want to do ... });

I then use update to handle when the task is complete ...

void update() {
  if(task.Complete) { ... do something with result ... }
}

Using my code I don't appear to get any locking problems.

The key difference I can see is that I limit the number of threads my tasking system can use, other than that it's pretty much the same approach.

I took a similar approach here:

https://github.com/TehWardy/ccoder-Voxels/tree/master/Assets/Tasks

My code basically does what the .Net 4 tasks stuff does (well some of it) in that I pass a lambda in and get a task back ....

var task = Task.Factory.StartNew(() => { return GenerateLotsOfData(); });

I then use update to handle when the task is complete ...

void update() {
  if(task.Complete) { var data = task.Result; }
}

Using my code I don't appear to get any locking problems.

The key difference I can see is that I limit the number of threads my tasking system can use, other than that it's pretty much the same approach.

Source Link
War
  • 1.7k
  • 1
  • 18
  • 33

I took a similar approach here:

https://github.com/TehWardy/ccoder-Voxels/tree/master/Assets/Tasks

My code basically does what the .Net 4 tasks stuff does (well some of it) in that I pass a lambda in and get a task back ....

var task = Task.Factory.StartNew(() => { ... stuff you want to do ... });

I then use update to handle when the task is complete ...

void update() {
  if(task.Complete) { ... do something with result ... }
}

Using my code I don't appear to get any locking problems.

The key difference I can see is that I limit the number of threads my tasking system can use, other than that it's pretty much the same approach.