Hi I have a jagged array 20 by 20, I try to match 700 different patterns in 8 different directions (built like smaller jagged arrays).
I would like to parallelize the loop that goes through each pattern. Since Unity doesn’t support Parallel.For what is the best way to achieve the same result?
Unity doesn’ t support multithreading for those who inherit any Unity class like Monobehaviour. If you want to use multithreading your class should be totally our of Unity
Alternatively, rather than creating and managing threads manually, you could use the ThreadPool - you use QueueUserWorkItem to queue up chunks of work (e.g. one work item per pattern) and the runtime will take care of farming the work out to threads for you.
You’ll probably want to use something like Interlocked.Increment to keep track of the number of completed work items, so that you know when all the work is finished.