Hi,
I'm a bit confused about how to properly use QueuedTask.Run().
If I have two or more API calls that require to be run on the MCT - do I wrap each of those calls individually into a QueuedTask.Run()? Or can I wrap all the calls under one giant QueuedTask.Run()? I am puzzled more, if I am to also allowed to wrap my own business logic under the QueuedTask.Run along with actual Pro SDK API calls that absolutely MUST be run under QueuedTask.Run(). Is this a bit of no no?
So lets look at some code:
if (map != null && isOverwriteMaps)
{
CloseMap(map.Name);
await CleanMap(map);
}
else
{
await QueuedTask.Run(() =>
{
map = MapFactory.Instance.CreateMap(mapName, MapType.Map, MapViewingMode.Map, Basemap.None);
});
await QueuedTask.Run(() =>
{
map.SetSpatialReference(SpatialReferenceBuilder.CreateSpatialReference(4326));
});
}
So I am using QueuedTask.Run three times - can I just use it once and wrap the whole thing or I right to use it for each individual case?
I think you have to be careful to run big blocks of code within QueuedTask.Run in case there is a call that requires it to be run on the GUI thread. Am I right in my thinking here?