Search code examples
c#.nethalcon

Multithreading computationally heavy tasks in HalconDotNet


For a project with a very large database I am using the following two procedures thousands of times in a loop:

select_points_object_model_3d()
render_object_model_3d()

This takes hours and hours for every test as it is using only 1/16 cores. Now I was wondering: Is there a way to run multiple HDev engines in different threads all executing said procedures?


Solution

  • I forgot to come back to this when I found a solution. For the next one who is stuck on this. Using taskList[i] = new Task<>(() => {"task code"}); I was able to run 450+ tasks that use HOP.SelectPointsObjectModel3d() and HOP.RenderObjectModel3d() consecutively completely utilizing all my cores. I didn't need multiple engines or anything like that.