Do I understand the threading concept right?

1101
3
Jump to solution
02-10-2020 07:54 AM
BarbaraSchneider2
Occasional Contributor II

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?

0 Kudos
1 Solution

Accepted Solutions
RichRuh
Esri Regular Contributor

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

View solution in original post

3 Replies
RichRuh
Esri Regular Contributor

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

BarbaraSchneider2
Occasional Contributor II

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.

0 Kudos
RichRuh
Esri Regular Contributor

Yes, this is correct.

More information about multithreading in the Pro SDK is available here: ProConcepts Framework · Esri/arcgis-pro-sdk Wiki · GitHub