As far as I understand, multithreading in the Pro SDK is used to separate the user interface thread from the worker thread, i.e. a user can still perform tasks in the GUI while the worker thread does its work.
Can I also split up time consuming tasks into multiple threads? In my application, I create some feature classes, and I assign renderers to the corresponding layers. I split this up into multiple threads as follows:
Task task = QueuedTask.Run(() => CreateFootprintFCAsync(fdPath, "Footprint", spatialRef));
task = QueuedTask.Run(() => CreatePerimeterFCAsync(fdPath, "Perimeter", spatialRef));
task = QueuedTask.Run(() => CreateHabitatFCAsync(fdPath, "Habitat", spatialRef));
However, this code doesn't run asynchronously, but sequentially. Am I doing something wrong or is this expected behaviour?
Solved! Go to Solution.
Queued Task sets up code so that it runs on the Main CIM Thread. This is a special thread used to access the geodatabase. So the behavior you are seeing is correct.
--Rich
Queued Task sets up code so that it runs on the Main CIM Thread. This is a special thread used to access the geodatabase. So the behavior you are seeing is correct.
--Rich
Thanks, Rich.
Is my assumption above correct?: multithreading in the Pro SDK is used to separate the user interface thread from the worker thread, i.e. a user can still perform tasks in the GUI while the worker thread does its work.
Yes, this is correct.
More information about multithreading in the Pro SDK is available here: ProConcepts Framework · Esri/arcgis-pro-sdk Wiki · GitHub