Open/Save/Coordsys Dialog Error

423
2
03-03-2020 07:24 AM
AdamDavis
Occasional Contributor

Hi,

At 2.5 still having issues getting dialogs to show correctly when used from within QueuedTask.Run.

The Coordinate System Dialog is the one from the snippet collection

This works from a button

protected override void OnClick()
{
new SaveItemDialog().ShowDialog();

new CoordinateSystemDialog().ShowDialog();
}

So does this

protected override void OnClick()
{
FrameworkApplication.Current.Dispatcher.Invoke(() => new SaveItemDialog().ShowDialog());

FrameworkApplication.Current.Dispatcher.Invoke(() => { new CoordinateSystemDialog().ShowDialog(); });
}

But this does not.

protected override void OnClick()
{
QueuedTask.Run(
() =>
{
FrameworkApplication.Current.Dispatcher.Invoke(() => new SaveItemDialog().ShowDialog());

FrameworkApplication.Current.Dispatcher.Invoke(() => { new CoordinateSystemDialog().ShowDialog(); });
});
}

The coordinate system dialog never completes loading. The Open/Save Dialogs do not show the contents of a fgdb. If I run the command again in the same session then the Open/Save Dialogs show the contents of a fgdb

Is there a workaround whilst it's being fixed?

Thanks,

Adam

0 Kudos
2 Replies
CharlesMacleod
Esri Regular Contributor

In general, calling a modal dialog from the queued task should be avoided.

protected override void OnClick()
{
    //construct on the UI
    var dlg = new SaveItemDialog();
    dlg.Title = "On QueuedTask";
    QueuedTask.Run(() =>
    {
	FrameworkApplication.Current.Dispatcher.Invoke(() => {
	  var result = dlg.ShowDialog();
	});
      });
    }
    ....
0 Kudos
AdamDavis
Occasional Contributor

Hi Charles,

Thanks for the code. I tried that and no difference - the first time the button is used entering a filegdb gives an infinitely scrolling wait icon. The 2nd time the button is used it shows the contents immediately.

it would be great if this could be made to work within the API whilst in QueuedTask.Run(). The realities of a very large code base don't always allow for being able to nip on/off the MCT at will. We have a code base that is entirely synchronous and are so are pragmatically wrapping our entire command in a single QueuedTask.Run().

Thanks,

Adam

0 Kudos