I noticed that LayerFactory.CreateLayer takes huge amount of time to add content of lyr file to a map. On my computer it takes more than 5 minutes to add simple layer (lyr file is attached – TestLayer.lyr).
I created simple test add-in to illustrate the problem (VS solution is attached – TestSlowCreateLayer.zip). Add-in contains the button (named Test slow CreateLayer) which calls
<SPAN class="keyword token">await</SPAN> QueuedTask<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Run</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">=</SPAN><SPAN class="operator token">></SPAN> LayerFactory<SPAN class="punctuation token">.</SPAN>Instance<SPAN class="punctuation token">.</SPAN><SPAN class="token function">CreateLayer</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">Uri</SPAN><SPAN class="punctuation token">(</SPAN>layerFilePath<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> MapView<SPAN class="punctuation token">.</SPAN>Active<SPAN class="punctuation token">.</SPAN>Map<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
where layerFilePath is the path of attached lyr file (TestLayer.lyr). After method is executed the message box with execution time will be shown.
I can reproduce this behavior for every lyr file I take. Layer data is very simple as you can see.
Also I noticed high CPU usage for ArcGIS Pro while layer is being created: 70-80%.
Environment:
CPU Intel Core i5-7200U
8 GB RAM
ArcGIS Pro 2.1
My add-in should work in ArcgIS Pro 2.1 so I need to get it work good on this version. I suppose 5 minutes for provided lyr file is more than it should be.