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.