Select to view content in your preferred language

Locking a layout during a long-running process

1506
5
01-27-2021 12:25 PM
AlanStewart
Frequent Contributor

I have a potentially long-running process in my add-in that processes a layout. Ideally I need to ensure the user cannot make changes to the layout and everything in the project it references, including maps and map layers, until this process is complete. The process makes no changes to anything in the layout or the project, only reads. What is the best strategy? I see elsewhere that cloning the layout is possible, but I would also need to clone the maps and layers. This seems an excessive demand. I've found the C# lock statement, but it does not allow use of await. There are a significant number of awaited calls to QueuedTask.Run() in the code.

Any suggestions or advice appreciated. I'm at Pro SDK 2.4.

0 Kudos
5 Replies
Amadeus111
Frequent Contributor

 

XAML (Probably DockPane1.xaml)
<UserControl ..../> 
<UserControl.Resources> 
    <Grid x:Name="YourGridName>
       <!--All your controls here that will be blocked during long process-->
    </Grid>

 

 

 

//C# (Probably Dockpane1.xaml.cs)
 private void LongProcessEventTriggered(object sender, EventArgs e)
        {
            QueuedTask.Run(() =>
            {
                Dispatcher.Invoke(() =>
                {
                    YourGridName.IsEnabled = false;
                });
             Do your stuff
                Dispatcher.Invoke(() =>
                {
                    YourGridName.IsEnabled = true;
                });
           }
            
            
        }

 

This is not proper MVVM but functions the same way

 

 

 

 

if you bind your grid/stackpanel etc. you probably wouldn't need dispatcher 

0 Kudos
AlanStewart
Frequent Contributor

I'm not sure what MainGrid is supposed to be, and am not familiar with 'binding', but I think you're suggesting disabling portions of the UI?

0 Kudos
KirkKuykendall1
Frequent Contributor

If you want to prevent user from doing anything while it runs, it seems like just showing a modal ProWindow via ShowDialog would work.

0 Kudos
AlanStewart
Frequent Contributor

Yes, that's a potential solution, though I have no objection to the user working in another layout in the project or on a map that is not referenced by the layout being processed. In the spirit the Pro application it seems like I should place minimal limitations on the user.

0 Kudos
AlanStewart
Frequent Contributor

I didn't mention in my original post that while most of the time the process only takes a few minutes, we have seen layouts that literally required hours for the process to complete. It would be nice if the user could still work on other layouts or on maps not referenced by the layout being processed while the process is taking place. Though I guess the users could always restrict their projects to  one layout per project and simply run and additional Pro session to continue work.

0 Kudos