I'm in Unity3D, and well, its API is a bit cumbersome, since it only lets you use its methods in the main thread, and well, and I want to use a Parallel.ForEach to accelerate a process. Basically, what I need to do is walk an IEnumerable ...
The problem is that the value of the IEnumerable comes from a method of the Unty3D API and of course, this IEnumerable did not use it (I do not materialize it) until I am inside the Parallel.ForEach (this is executed in another thread) therefore I am receiving an error. I would like to know if there is any way to make it lose the reference or to materialize it (without using .ToList (), since what I have seen is a very heavy method).
The code works perfectly without materializing it, since I have tried everything in the main thread, but as I say, to the star within Unity something I have to do, the optimal thing would be to leave it unrealized and work with this IEnumerable as it is . Since the very fact of materializing it will consume unnecessary resources.
The code that I have right now is as follows:
I just went back to how everything was before. That would not work for me.
What can I do?