<?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: Speed of code in ArcGis Extension in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/speed-of-code-in-arcgis-extension/m-p/648297#M17396</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;ArcMaps use a model which ESRI refers to as threads in isolation which is a fancy way of saying that all access to them is marshalled back to the creation thread, i.e. they are not multi-threaded.&amp;nbsp; The way that all of this works is that Single Threaded Apartments (STA) are used by ArcObjects and they get messages across apartments/threads when the Windows message pump runs.&amp;nbsp; If the messages are not pumping then nothing will be heard.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What I wanted to understand is how exactly you structured your code because of the above discussion.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You should be able to set breakpoints and/or log messages which will tell you where the delay is.&amp;nbsp; My guess is that it is related to the above.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 24 May 2011 09:56:36 GMT</pubDate>
    <dc:creator>RichardWatson</dc:creator>
    <dc:date>2011-05-24T09:56:36Z</dc:date>
    <item>
      <title>Speed of code in ArcGis Extension</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/speed-of-code-in-arcgis-extension/m-p/648293#M17392</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a serious issue regarding the speed of the code I am writing in my ArcGIS extension:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have written a process in order to read some data from an access database. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;- The ArcGis extension is controlling a TCP/IP server such that the database path can be received from an XML sent over the network.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- There is also a command button that allows doing the same thing by specifying manually the database path (it is also calling the IExtension function on the onclick event).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;both ways work correctly &lt;/SPAN&gt;&lt;STRONG&gt;with the TCP/IP server turned on&lt;/STRONG&gt;&lt;SPAN&gt;. However the click on the button is much much more faster (1s againt 7min) that the network&amp;nbsp; stuff. The problem is not coming from the network communication because the database path is received very quickly (I checked by debugging).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does someone have an idea? I am quite desesperate because I don't have any clue how to solve it!!!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a lot&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 May 2011 13:58:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/speed-of-code-in-arcgis-extension/m-p/648293#M17392</guid>
      <dc:creator>ThibautDusanter</dc:creator>
      <dc:date>2011-05-23T13:58:37Z</dc:date>
    </item>
    <item>
      <title>Re: Speed of code in ArcGis Extension</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/speed-of-code-in-arcgis-extension/m-p/648294#M17393</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi,&lt;BR /&gt;- The ArcGis extension is controlling a TCP/IP server such that the database path can be received from an XML sent over the network.&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I suspect that the problem lies here.&amp;nbsp; What does the code specially do?&amp;nbsp; I am wondering how you are notified that "the XML was sent over the network".&amp;nbsp; Did you create a different thread?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 May 2011 21:09:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/speed-of-code-in-arcgis-extension/m-p/648294#M17393</guid>
      <dc:creator>RichardWatson</dc:creator>
      <dc:date>2011-05-23T21:09:17Z</dc:date>
    </item>
    <item>
      <title>Re: Speed of code in ArcGis Extension</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/speed-of-code-in-arcgis-extension/m-p/648295#M17394</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you for your response.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So there is another Command button that is starting a TcpListener. The TcpListener is associated with a new thread to listen to new clients. And each client is associated to one thread in order to listen to new data.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The thing is that this server is always turned on while testing (both for the command through xml or command through button click option). So to my mind it can´t be responsible for the slowing down.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What do you think?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a lot,&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 May 2011 06:35:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/speed-of-code-in-arcgis-extension/m-p/648295#M17394</guid>
      <dc:creator>ThibautDusanter</dc:creator>
      <dc:date>2011-05-24T06:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: Speed of code in ArcGis Extension</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/speed-of-code-in-arcgis-extension/m-p/648296#M17395</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;After reading your message, i may have found the solution &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Calling ArcObjects from a thread other than the main thread&lt;BR /&gt;In many multithreading applications, you will need to make calls to ArcObjects from different running threads. For example, you might have a background thread that gets a response from a Web service, which, in turn, should add a new item to the map display, change the map extent, or run a geoprocessing (GP) tool to perform some type of analysis.&lt;BR /&gt;A very common case is calling ArcObjects from a timer event handler method. A timer's elapsed event is raised on a ThreadPool task (a thread that is not the main thread). Yet it needs to use ArcObjects, which seems like it would require cross-apartment calls. However, this can be avoided by treating the ArcObjects component as if it were a UI control and using Invoke to delegate the call to the main thread where the ArcObjects component is created. Thus, no cross-apartment calls are made.&lt;BR /&gt;The ISynchronizeInvoke interface includes the Invoke, BeginInvoke, and EndInvoke methods. Implementing these methods can be a daunting task. Instead, have your class directly inherit from System.Windows.Forms.Control or have a helper class that inherits Control. Either option provides a simple and efficient solution for invoking methods.&lt;BR /&gt;The following code example uses a user-defined InvokeHelper class to invoke a timer�??s elapsed event handler to re-center the map's visible bounds and set the map's rotation.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am going to investigate this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is it what you were refering to rlwatson?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 May 2011 09:03:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/speed-of-code-in-arcgis-extension/m-p/648296#M17395</guid>
      <dc:creator>ThibautDusanter</dc:creator>
      <dc:date>2011-05-24T09:03:28Z</dc:date>
    </item>
    <item>
      <title>Re: Speed of code in ArcGis Extension</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/speed-of-code-in-arcgis-extension/m-p/648297#M17396</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;ArcMaps use a model which ESRI refers to as threads in isolation which is a fancy way of saying that all access to them is marshalled back to the creation thread, i.e. they are not multi-threaded.&amp;nbsp; The way that all of this works is that Single Threaded Apartments (STA) are used by ArcObjects and they get messages across apartments/threads when the Windows message pump runs.&amp;nbsp; If the messages are not pumping then nothing will be heard.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What I wanted to understand is how exactly you structured your code because of the above discussion.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You should be able to set breakpoints and/or log messages which will tell you where the delay is.&amp;nbsp; My guess is that it is related to the above.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 May 2011 09:56:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/speed-of-code-in-arcgis-extension/m-p/648297#M17396</guid>
      <dc:creator>RichardWatson</dc:creator>
      <dc:date>2011-05-24T09:56:36Z</dc:date>
    </item>
    <item>
      <title>Re: Speed of code in ArcGis Extension</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/speed-of-code-in-arcgis-extension/m-p/648298#M17397</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hey rlwatson,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I found the solution using the example "&lt;/SPAN&gt;&lt;STRONG&gt;Calling ArcObjects from a thread other than the main thread&lt;/STRONG&gt;&lt;SPAN&gt;" in the page:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//000100000100000000"&gt;http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//000100000100000000&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I used an InvokeHelper class as mentioned.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regarding the debugging with breakpoints/log message (as you suggested), I tried it before and it was not working. The problem really lies in the fact that I was calling the function from another thread (the thread of network listening).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you for your help&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 May 2011 06:25:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/speed-of-code-in-arcgis-extension/m-p/648298#M17397</guid>
      <dc:creator>ThibautDusanter</dc:creator>
      <dc:date>2011-05-25T06:25:55Z</dc:date>
    </item>
  </channel>
</rss>

