Sorry, my post was too short. The entire code to programmatically load stereo images into a stereo map is the following:
await QueuedTask.Run(() =>
{
CIMMap cimMap = stereoMap.GetDefinition();
var stereoProps = cimMap.StereoProperties;
WorkspaceFactory workspaceFactory = WorkspaceFactory.FileGDB;
var fileGdbConnPath = new FileGeodatabaseConnectionPath(new Uri(gdbPath, UriKind.Absolute));
Geodatabase gdb = new Geodatabase(fileGdbConnPath);
string workspaceConnectionString = gdb.GetConnectionString();
using (var fileGdb = new Geodatabase(fileGdbConnPath))
{
MosaicDataset mosaicDataset = fileGdb.OpenDataset<MosaicDataset>(mosaicName);
CIMStandardDataConnection mosaicDataConnection = new CIMStandardDataConnection()
{
WorkspaceConnectionString = workspaceConnectionString,
WorkspaceFactory = workspaceFactory,
Dataset = mosaicName,
DatasetType = esriDatasetType.esriDTMosaicDataset
};
var (leftImageID, rightImageID) = GetStereoImages(mosaicDataset);
stereoProps.SourceType = StereoSourceType.StereoModelCollection;
stereoProps.StereoModelCollection = mosaicDataConnection;
stereoProps.LeftImageID = leftImageID;
stereoProps.RightImageID = rightImageID;
cimMap.StereoProperties = stereoProps;
stereoMap.SetDefinition(cimMap);
}
return Task.CompletedTask;
});
Even though I put the entire code within a queued task and I await for it (await QueuedTask.Run(() =>), the code runs away when I call Geodatabase gdb = new Geodatabase(fileGdbConnPath), and I 'm not able to wait until the stereo images are loaded.
I have to wait until the images are loaded before I can load layers to the stereo map. Alternatively, I could wait for the images to be loaded in the method OnDrawComplete(MapViewEventArgs args) in my module. This would be a workaround.
Thanks for your help anyway.