|
POST
|
BackgroundTask is 2.6 fyi. In the meanwhile u can try something like this - note: u cant use a Task directly because Tasks are MTA. Anyway, make sure u read all the fine print. Dont run anything off the MCT that alters the application. //http://stackoverflow.com/questions/16720496/set-apartmentstate-on-a-task
internal class BackgroundTaskTemp
{
public static Task Run(TaskPriority priority, Action action)
{
var tcs = new TaskCompletionSource<bool>();
Thread thread = new Thread(() =>
{
try
{
action();
tcs.SetResult(true);
}
catch (Exception e)
{
tcs.SetException(e);
}
});
thread.Priority = FromTaskPriority(priority);
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
return tcs.Task;
}
public static Task<T> Run<T>(TaskPriority priority, Func<T> func)
{
var tcs = new TaskCompletionSource<T>();
Thread thread = new Thread(() =>
{
try
{
tcs.SetResult(func());
}
catch (Exception e)
{
tcs.SetException(e);
}
});
thread.Priority = FromTaskPriority(priority);
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
return tcs.Task;
}
private static ThreadPriority FromTaskPriority(TaskPriority priority)
{
if (priority == TaskPriority.high)
return ThreadPriority.Highest;
if (priority == TaskPriority.single)
throw new InvalidOperationException("Sorry, no can do - wait for 2.6 and the proper BackgroundTask");
else return ThreadPriority.Normal;
}
}
} usage: var layout = LayoutView.Active?.Layout;
if (layout == null)
return;
await QueuedTask.Run(() =>
{
...
//export on the background thread
//ArcGIS.Core.Threading.Tasks.BackgroundTask.Run(
//ArcGIS.Core.Threading.Tasks.TaskPriority.normal,
// () => layout.Export(pdf),
//ArcGIS.Core.Threading.Tasks.BackgroundProgressor.None);
BackgroundTaskTemp.Run(
ArcGIS.Core.Threading.Tasks.TaskPriority.normal,
() => layout.Export(pdf));
...
...
});
... View more
04-14-2021
09:58 AM
|
0
|
2
|
4923
|
|
POST
|
export looks like a good candidate for the BackgroundTask so u might want to consider using _that_ rather than the QueuedTask. Obviously switching threads doesnt make something _quicker_ but it will free up the QueuedTask to allow u to get on with your other business. var layout = LayoutView.Active?.Layout;
if (layout == null)
return;
await QueuedTask.Run(() =>
{
var def = layout.GetDefinition() as CIMLayout;
//Make changes...
//Commit changes
layout.SetDefinition(def);
//Tee-up export - add-in is responsible for checking
//validity of OutputFileName
var pdf = new PDFFormat()
{
Resolution = 300,
OutputFileName = $"C:\\temp\\{layout.Name}.pdf"
};
//Export on a background thread
ArcGIS.Core.Threading.Tasks.BackgroundTask.Run(
ArcGIS.Core.Threading.Tasks.TaskPriority.normal,
() => layout.Export(pdf),
ArcGIS.Core.Threading.Tasks.BackgroundProgressor.None);
//We are still on the QueuedTask here...
//continue doing work but be mindful that your layout may
//still be exporting
...
});
U can read more about it here: https://github.com/esri/arcgis-pro-sdk/wiki/ProConcepts-Asynchronous-Programming-in-ArcGIS-Pro#using-backgroundtask . The most important thing to remember when using BackgroundTask is to never change application state_. That is what the CIM thread, or MCT as we call it is for, and that is accessed via QueuedTask.
... View more
04-13-2021
01:53 PM
|
0
|
4
|
4937
|
|
POST
|
do u mind providing your usercontrol xaml or some xaml that provides a repro and I'll forward to the UI team
... View more
04-13-2021
12:28 PM
|
0
|
1
|
2733
|
|
POST
|
you might be better off going against the layout CIM definition. See the code snippet below. var layout = LayoutView.Active?.Layout;
if (layout == null)
return;
await QueuedTask.Run(() =>
{
var def = layout.GetDefinition() as CIMLayout;
var graphic_elements = def.Elements.OfType<CIMGraphicElement>().ToList()
?? new List<CIMGraphicElement>();
bool changed = false;
var when = DateTime.Now.ToString("G");
int c = 0;
foreach (var ge in graphic_elements)
{
if (ge.Graphic is CIMTextGraphic textGraphic)
{
textGraphic.Text = $"Changed {c++}, {when}";
changed = true;
}
}
if (changed)
//commit the changes
layout.SetDefinition(def);
}); If u want to find out more about the CIM take a look at this video: ArcGIS Pro SDK for .NET: Understanding the CIM, a Guide for Developers
... View more
04-13-2021
10:22 AM
|
0
|
6
|
4942
|
|
POST
|
https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/#topic29485.html
... View more
03-16-2021
11:29 AM
|
0
|
1
|
4296
|
|
POST
|
This is what I see in the ADMapping.daml. <splitButton id="esri_mapping_locateSplitButton" keytip="L" extendedCaption="Search for addresses">
<button refID="esri_mapping_showLocateDockPane"/>
<gallery refID="esri_mapping_locateGallery"/>
</splitButton> So, I think if u reference the locateSplitButton rather than the showLocateDockPane u will be good to go.
... View more
03-01-2021
10:47 AM
|
1
|
0
|
2195
|
|
POST
|
looking in the ADMapping.daml I see this: <customControl id="esri_mapping_downloadMap" caption="Download Map" className="ArcGIS.Desktop.Internal.Mapping.Ribbon.DownloadMap" disableIfBusy="true" showHelp="true" staysOpenOnClick="true" isDropDown="true"
...>
<content className="ArcGIS.Desktop.Internal.Mapping.Ribbon.DownloadMapControl" />
...
</customControl> Note the staysOpenOnClick and IsDropDown attributes. I think those are what you are after. You can find the ADMapping.daml here: <your Pro install location>/bin/Extensions/Mapping and here: https://github.com/Esri/arcgis-pro-sdk/wiki/DAML-ID-Reference-ADMapping.daml
... View more
03-01-2021
10:42 AM
|
2
|
1
|
4801
|
|
POST
|
try these two examples. They should get u started.....but there are many more examples on this page: https://github.com/esri/arcgis-pro-sdk/wiki/ProSnippets-Geodatabase#opening-a-file-geodatabase-given-the-path https://github.com/esri/arcgis-pro-sdk/wiki/ProSnippets-Geodatabase#searching-a-featureclass-using-spatialqueryfilter
... View more
02-08-2021
01:49 PM
|
0
|
1
|
2738
|
|
IDEA
|
Hi Stephen, I think you'll find the option you are looking for here:
... View more
01-29-2021
05:03 PM
|
0
|
0
|
3861
|
|
POST
|
https://github.com/esri/arcgis-pro-sdk/wiki/ProGuide-Custom-Dictionary-Style
... View more
01-14-2021
02:29 PM
|
0
|
0
|
1406
|
|
POST
|
Kirk, I dug into this a little deeper. It looks like, in some cases, particular symbolsets have a "000000 - Unspecified" symbol entity as the default. The Atmospheric symbols - symbolset 45 and 46 as examples. So the initial pick of the METOCPoints, Lines, Polys triggers a search for the default entity: "symbolentity 0". Now, I _think_ the GetDictionarySymbol used to return a default symbol for undefined entities?? - but it could just be a bug in the sample - anyway, when I select a "real" entity from the symbolentity drop down (i.e. something other than 000000 - eg 110100), I get the correct symbol retrieved and loaded. I think the best thing to do is simply wrap the GetDictionarySymbol call in a try/catch to prevent the null symbol being returned from blowing up the dockpane in those cases where an unspecified "000000" symbol is being requested. private Task<ImageSource> GenerateBitmapImageAsync(Dictionary<string, object> attributes) {
return QueuedTask.Run(() => {
try {
CIMSymbol symbol =
ArcGIS.Desktop.Mapping.SymbolFactory.Instance.GetDictionarySymbol(
"mil2525d", attributes);
var si = new SymbolStyleItem() {
Symbol = symbol,
PatchHeight = 64,
PatchWidth = 64
};
return si.PreviewImage;
}
catch(NullReferenceException) {
return null;
}
});
}
... View more
01-13-2021
01:14 PM
|
0
|
1
|
2857
|
|
POST
|
Hi Kirk, looks like a bug in GetDictionarySymbol. I'll keep u posted.
... View more
01-13-2021
12:14 PM
|
1
|
0
|
2863
|
|
POST
|
I see. Thanks for that. What I told Mody to do was run a console executable, not Pro. However, for that console executable to run, it will need Pro installed. The console executable will need two references - the ArcGIS.Core and ArcGIS.CoreHost dlls - hence the name "CoreHost".
... View more
01-13-2021
12:12 PM
|
1
|
1
|
2721
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 05-19-2026 10:29 AM | |
| 1 | 04-29-2026 02:06 PM | |
| 1 | 01-08-2026 02:03 PM | |
| 1 | 01-08-2026 02:15 PM | |
| 3 | 12-17-2025 11:33 AM |
| Online Status |
Offline
|
| Date Last Visited |
4 weeks ago
|