Quantcast
Channel: Questions in topic: "dll"
Viewing all articles
Browse latest Browse all 706

How to prevent heavy method calculation from locking Unity up?

$
0
0
Hello, everyone! Right now Im having an issue with a method, called from a DLL, in which it can take a long time before this method finishes its calculation and in the mean time I simply cannot use anything on Unity. I tried using a thread (see below) so that Unity could continue its tasks while my method calculation was being done, but that didnt work out. IntPtr resultPointer = default(IntPtr); Debug.Log( "Startin thread... " ); System.Threading.Thread thread = new System.Threading.Thread( () => { resultPointer = computeMinBox3D( _pointsFloatVector.Length, _pointsFloatVector, 8 ); } ); thread.Start( ); thread.Join( ); Debug.Log( "Thread work done!" ); I read some of the coroutine documentation and figured it wouldnt solve my problem either. My second try is the following: private IEnumerator YieldComputeMinBox3D( int pointsFloatVectorLength, float[] pointsFloatVector, int numThread ) { _resultPointer = computeMinBox3D( pointsFloatVectorLength, pointsFloatVector, numThread ); yield return null; } Altough this one does prevent Unity from locking up it also doesnt execute the method correctly, it seems to just skip its heavy calculation completely and doesnt continue where it is supposed to. What am I missing here? Extra question: The method Im calling is already multithreaded. Would this be a problem?

Viewing all articles
Browse latest Browse all 706

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>