I have a problem with deactivating my custom map tool when sketch is finished.
At now I'm trying to call SetCurrentToolAsync from the OnSketchCompleteAsync of my map tool. But this causes deadlock. Seems like I need to exit from OnSketchCompleteAsync to proceed with changing the current tool.
I want to deactivate the tool when sketch is completed. I didn't found any property in the MapTool class to specify this behavior. Is this possible?
Solved! Go to Solution.
Max,
Try setting the applications current tool to null (or anything else).
If its null then 'explore' mode will be active.
protected override Task<bool> OnSketchCompleteAsync(Geometry geometry)
{
//do something productive with the sketch and deactivate
ArcGIS.Desktop.Framework.FrameworkApplication.SetCurrentToolAsync(null);
return base.OnSketchCompleteAsync(geometry);
}
Max,
Try setting the applications current tool to null (or anything else).
If its null then 'explore' mode will be active.
protected override Task<bool> OnSketchCompleteAsync(Geometry geometry)
{
//do something productive with the sketch and deactivate
ArcGIS.Desktop.Framework.FrameworkApplication.SetCurrentToolAsync(null);
return base.OnSketchCompleteAsync(geometry);
}
Got into the same issue, couldn't figure out that the deadlock was await's fault.
In any case it still works with the handler marked as async for those who need to keep it, you just need to take away the await statement from the call (even though intellisense will give a warning about it):
protected override async Task<bool> OnSketchCompleteAsync(Geometry geometry)
{
//do something productive with the sketch and await
//all the calls needing to be awaited
ArcGIS.Desktop.Framework.FrameworkApplication.SetCurrentToolAsync(null);
return true;
}