- Home /
Unity Backgroundworker threading
I am currently working on a Voxel type game and I am wondering, Is there a way to call the complete event for a backgroundworker thread on the unity thread itself? I am running into errors when my thread tries to call unity functions from its completed event handler function. Is there a way to call an event for a thread finishing on the Main thread without blocking it using Join()?
I need to use threading because terrain generation is very intensive and causes many hiccups to the graphics. If this is not possible, are there any other alternatives to asynchronously generate data in the background AND catch it finishing?
Answer by luchoscar · May 08, 2014 at 05:09 PM
This post can actually answer your question on threding and unity api. As far as i understand you cannot have a thread communicate with the api. You can probably try generating the data using compute shaders and then bind it to an object to render the terrain, the other thing could do, although i'm not sure that will work so you could try it, is to create data on a separate thread using your own functions to create data to then pass to the variable that is going to be use by the api. I've done something similar when working with UIs in .NET and i used delegates but i dont know if unity supports those
Edit: forgot to add the link to the post http://answers.unity3d.com/questions/180243/threading-in-unity.html
Your answer
![](https://koobas.hobune.stream/wayback/20220613134232im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multithreading, Waiting for threads to complete. 0 Answers
Does Unity 4.0 support ActionScript Workers for FlashPlayer 11.4? 1 Answer
"...can only be called from the main thread" - MultiThreading 1 Answer
[C#] How to use a Multi Threaded Job Queue for Math function 2 Answers
How does unity thread works? 0 Answers