<?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: Working with a Map Document causes my program to freeze. in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/working-with-a-map-document-causes-my-program-to/m-p/299013#M7771</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Kingsley, thank you for your reply.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I agree that it smells like a threading deadlock.&amp;nbsp; However, Since I'm not doing any threading in this process, if it is a threading issue it must be internal to the ArcObject calls.&amp;nbsp; I know that it's possible that what I'm doing outside of the library calls can affect what happens inside, but I don't know in what way.&amp;nbsp; Partly that's what I was hoping someone could tell me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;About the Status() call, I initially was just setting the lblStatus.Caption property, but the form window didn't change until the whole process was finished and it said "Done."&amp;nbsp; Calling ProcessMessages allows the form to refresh and show the latest status text that was sent to it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried your suggestion and commented out the internals of Status(), and it still freezes, only it won't tell me where.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your question about the target platform got me wondering.&amp;nbsp; It's definitely x86.&amp;nbsp; I've been running it on Windows 7, so I thought I would try it on an XP box that I had available and I could not get it to freeze on the XP box.&amp;nbsp; I then had a few of my colleagues try it on their Windows 7 computers and some could get it to freeze and some could not.&amp;nbsp; I'm trying to identify patterns but I'm not finding anything yet.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 17 Feb 2011 16:30:19 GMT</pubDate>
    <dc:creator>ThomasBates</dc:creator>
    <dc:date>2011-02-17T16:30:19Z</dc:date>
    <item>
      <title>Working with a Map Document causes my program to freeze.</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/working-with-a-map-document-causes-my-program-to/m-p/299011#M7769</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;First off, I'm using Delphi 2007 and ArcObjects 9.3.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My application has a bit of start-up code that loads a map document, updates the feature layers to make sure they are looking at the correct File GeoDatabase, and saves the map document again.&amp;nbsp; Then, the updated map document gets loaded into the map control and everything looks beautiful.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;THE CATCH is that this works sometimes, but not all the time.&amp;nbsp; When I run it from the Delphi IDE, it works about 99% of the time.&amp;nbsp; When I run the executable file directly, it fails about 90% of the time.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When it fails, it doesn't throw an exception or anything, it just freezes.&amp;nbsp; And it freezes in random places:&amp;nbsp; sometimes in the middle of the "Save" call, the "Close" call, the "Get_UsesRelativePaths" call, and sometimes while leaving the method that contains the ArcObjects calls.&amp;nbsp; And sometimes not at all.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I created a little stand-alone application with just the bit of start-up code, and it shows the same behaviour.&amp;nbsp; I then started removing bits to try to isolate the cause.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I started by commenting out the code that modifies the feature layers.&amp;nbsp; It still froze.&amp;nbsp; Then I continued until the code was only opening the MapDocument, accessing the Map and then closing the document again.&amp;nbsp; It still froze.&amp;nbsp; I then commented out the Get_Map call and after repeated tries I could not get it to freeze when it was just opening and closing the map document.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the method that I'm working with:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
procedure TMain.UpdateMapDocument(AMapDocumentFileName, AWorkspacePath: string);
var
&amp;nbsp; mapDocument:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IMapDocument;
&amp;nbsp; isMapDocument:&amp;nbsp;&amp;nbsp;&amp;nbsp; WordBool;
&amp;nbsp; map:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IMap;
&amp;nbsp; useRelativePaths: WordBool;
begin
&amp;nbsp; Status('Updating Map Document ...');

&amp;nbsp; if FileExists(AMapDocumentFileName) and DirectoryExists(AWorkspacePath) then
&amp;nbsp; begin

&amp;nbsp;&amp;nbsp;&amp;nbsp; Status('Creating Map Document');
&amp;nbsp;&amp;nbsp;&amp;nbsp; mapDocument := CoMapDocument.Create as IMapDocument;

&amp;nbsp;&amp;nbsp;&amp;nbsp; Status('Testting Map Document');
&amp;nbsp;&amp;nbsp;&amp;nbsp; mapDocument.Get_IsMapDocument(AMapDocumentFileName, isMapDocument);
&amp;nbsp;&amp;nbsp;&amp;nbsp; if isMapDocument then
&amp;nbsp;&amp;nbsp;&amp;nbsp; begin
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Status('Opening Map Document');
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mapDocument.Open(AMapDocumentFileName, '');

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Status('Opening Map');
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mapDocument.Get_Map(0, map);

{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //&amp;nbsp; Status('Updating Feature Layer Connections');
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //&amp;nbsp; UpdateFeatureLayerConnections(AWorkspacePath, map);

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Status('Saving Map');
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mapDocument.ReplaceContents(map as IMxdContents);

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Status('Getting Relative Units');
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mapDocument.Get_UsesRelativePaths(useRelativePaths);

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Status('Saving Map Document');
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mapDocument.Save(useRelativePaths, False);
}

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Status('Closing Map Document');
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mapDocument.Close;
&amp;nbsp;&amp;nbsp;&amp;nbsp; end;
&amp;nbsp; end;

&amp;nbsp; Status('... Updated Map Document');
end;
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've also attached the whole little test project.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When it works, it works exactly as expected so it seems that I'm doing this correctly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm hoping someone can see something that I'm doing wrong that may be causing the freezing, or that someone has seen this freezing before and knows a work-around to avoid it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thomas Bates.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Feb 2011 17:31:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/working-with-a-map-document-causes-my-program-to/m-p/299011#M7769</guid>
      <dc:creator>ThomasBates</dc:creator>
      <dc:date>2011-02-16T17:31:18Z</dc:date>
    </item>
    <item>
      <title>Re: Working with a Map Document causes my program to freeze.</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/working-with-a-map-document-causes-my-program-to/m-p/299012#M7770</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The freezing sounds very much like a threading deadlock of sorts. Just out of curiosity, what happens if you remove the &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;Application.ProcessMessages&lt;/SPAN&gt;&lt;SPAN&gt; from your Status() procedure? Alternatively comment out all code in Status() and see if anything changes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not sure if you have the option to compile to x64 in Delphi, but in .NET we've seen some pretty erratic behavior when forgetting to specify an x86 target platform.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You may find this of interest:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Programming with ArcObjects 9.3 in Delphi 7, 2005, 2006, 2007, and 2009&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://arcscripts.esri.com/details.asp?dbid=14204"&gt;http://arcscripts.esri.com/details.asp?dbid=14204&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Feb 2011 06:35:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/working-with-a-map-document-causes-my-program-to/m-p/299012#M7770</guid>
      <dc:creator>KingsleyPayne</dc:creator>
      <dc:date>2011-02-17T06:35:24Z</dc:date>
    </item>
    <item>
      <title>Re: Working with a Map Document causes my program to freeze.</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/working-with-a-map-document-causes-my-program-to/m-p/299013#M7771</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Kingsley, thank you for your reply.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I agree that it smells like a threading deadlock.&amp;nbsp; However, Since I'm not doing any threading in this process, if it is a threading issue it must be internal to the ArcObject calls.&amp;nbsp; I know that it's possible that what I'm doing outside of the library calls can affect what happens inside, but I don't know in what way.&amp;nbsp; Partly that's what I was hoping someone could tell me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;About the Status() call, I initially was just setting the lblStatus.Caption property, but the form window didn't change until the whole process was finished and it said "Done."&amp;nbsp; Calling ProcessMessages allows the form to refresh and show the latest status text that was sent to it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried your suggestion and commented out the internals of Status(), and it still freezes, only it won't tell me where.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your question about the target platform got me wondering.&amp;nbsp; It's definitely x86.&amp;nbsp; I've been running it on Windows 7, so I thought I would try it on an XP box that I had available and I could not get it to freeze on the XP box.&amp;nbsp; I then had a few of my colleagues try it on their Windows 7 computers and some could get it to freeze and some could not.&amp;nbsp; I'm trying to identify patterns but I'm not finding anything yet.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Feb 2011 16:30:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/working-with-a-map-document-causes-my-program-to/m-p/299013#M7771</guid>
      <dc:creator>ThomasBates</dc:creator>
      <dc:date>2011-02-17T16:30:19Z</dc:date>
    </item>
    <item>
      <title>Re: Working with a Map Document causes my program to freeze.</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/working-with-a-map-document-causes-my-program-to/m-p/299014#M7772</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Does the problem occur with any map document, or are you always testing using the same Mxd?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Feb 2011 07:29:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/working-with-a-map-document-causes-my-program-to/m-p/299014#M7772</guid>
      <dc:creator>KingsleyPayne</dc:creator>
      <dc:date>2011-02-18T07:29:00Z</dc:date>
    </item>
    <item>
      <title>Re: Working with a Map Document causes my program to freeze.</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/working-with-a-map-document-causes-my-program-to/m-p/299015#M7773</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;We have three Mxd files that I've been testing with and they all do the same thing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, thanks for the link.&amp;nbsp; I've been going through the document and I don't know yet if anything in it will help with this immediate problem, but it will definitely help in general.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Feb 2011 17:04:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/working-with-a-map-document-causes-my-program-to/m-p/299015#M7773</guid>
      <dc:creator>ThomasBates</dc:creator>
      <dc:date>2011-02-22T17:04:05Z</dc:date>
    </item>
  </channel>
</rss>

