<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to open ProWindow within QueuedTask from RowCreatedEvent? in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-open-prowindow-within-queuedtask-from/m-p/1266267#M9522</link>
    <description>&lt;P&gt;I am running into this exact same issue except I am calling the ProWindow inside of a map tool's OnSketchCompleteAsync method. My command buttons are greyed out (seemingly due to a thread lock)! Hoping someone has figured this out!&lt;/P&gt;</description>
    <pubDate>Thu, 09 Mar 2023 22:55:05 GMT</pubDate>
    <dc:creator>afishdev</dc:creator>
    <dc:date>2023-03-09T22:55:05Z</dc:date>
    <item>
      <title>How to open ProWindow within QueuedTask from RowCreatedEvent?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-open-prowindow-within-queuedtask-from/m-p/1229267#M9035</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;I'm hoping to open a ProWindow on a RowCreatedEvent/RowModifiedEvent, but I'm getting an error saying "the calling thread cannot access this object because a different thread owns it".&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Essentially, I'm trying to take user input to force update several attributes on the row being created.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I've tried wrapping everything in the Current.Dispatcher.Invoke() but then my OK relay command is disabled (I assume because the thread is locked).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;My code is as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public static void OnRowCreated(RowChangedEventArgs args)
        {
            CreateLotWindow createLotWindow = new CreateLotWindow();
            createLotWindow.Owner = FrameworkApplication.Current.MainWindow; //errors out here
            var vm = createLotWindow.DataContext as CreateLotWindowViewModel;
            if (createLotWindow.ShowDialog() == true)
            {
                string lotNo = vm.LotCount;
                QueuedTask.Run(()=&amp;gt; {
                     // do stuff with user input
                }
            }
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Any help is greatly appreciated!&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2022 23:44:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-open-prowindow-within-queuedtask-from/m-p/1229267#M9035</guid>
      <dc:creator>succip</dc:creator>
      <dc:date>2022-11-08T23:44:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to open ProWindow within QueuedTask from RowCreatedEvent?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-open-prowindow-within-queuedtask-from/m-p/1266267#M9522</link>
      <description>&lt;P&gt;I am running into this exact same issue except I am calling the ProWindow inside of a map tool's OnSketchCompleteAsync method. My command buttons are greyed out (seemingly due to a thread lock)! Hoping someone has figured this out!&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2023 22:55:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-open-prowindow-within-queuedtask-from/m-p/1266267#M9522</guid>
      <dc:creator>afishdev</dc:creator>
      <dc:date>2023-03-09T22:55:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to open ProWindow within QueuedTask from RowCreatedEvent?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-open-prowindow-within-queuedtask-from/m-p/1266291#M9523</link>
      <description>&lt;P&gt;It'd take me some time to reorient myself in the old project but I can share my current code that does work.&lt;/P&gt;&lt;P&gt;Here's where the window's opened, note the use of BeginInvoke:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;ProApp.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)(() =&amp;gt;
                {
                    OpenPlanListWindow();
                }));&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And here's my OpenPlanListWindow() function:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private static async void OpenPlanListWindow()
        {
            var planListWindow = new PlanListWindow();
            planListWindow.Owner = FrameworkApplication.Current.MainWindow;
            var planListWindowVM = new PlanListWindowViewModel { Plans = _planList };
            planListWindow.DataContext = planListWindowVM;
            var dialogResult = planListWindow.ShowDialog();
            if (dialogResult == true)
            {
                await QueuedTask.Run(() =&amp;gt;
                {
                    Table lotsTable = Data.Sde.OpenDataset&amp;lt;Table&amp;gt;("SPATIAL.cadLots");
                    Inspector insp = new Inspector();
                    insp.Load(lotsTable, _editedOid);
                    var op = new EditOperation();
                    op.Modify(insp);
                    op.Execute();
                });
            }
            else
            {
                if (MapView.Active.Map.OperationManager.CanUndo)
                {
                    await MapView.Active.Map.OperationManager.UndoAsync();
                    FrameworkApplication.AddNotification(new Notification()
                    {
                        Message = "Lot edit canceled",
                        Title = "Operation Canceled"
                    });
                }
            }
        }&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 09 Mar 2023 23:08:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-open-prowindow-within-queuedtask-from/m-p/1266291#M9523</guid>
      <dc:creator>succip</dc:creator>
      <dc:date>2023-03-09T23:08:23Z</dc:date>
    </item>
  </channel>
</rss>

