<?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: Multi-threading in ArcObjects... in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/multi-threading-in-arcobjects/m-p/240726#M6221</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;OK...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I was able to do it without having a Windows form in the application, but the moment I call the form, I get the following loader lock message:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;"LoaderLock was detected.&lt;BR /&gt;Message: Attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;... and I am unable to proceed further!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried marking the form's Main method as &amp;lt;STAThread()&amp;gt; _, but still the same issue...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;PS: I am working in VB.Net with VS 2005 &amp;amp; ArcGIS 9.2&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 16 Nov 2010 10:28:51 GMT</pubDate>
    <dc:creator>UjjwalNigam</dc:creator>
    <dc:date>2010-11-16T10:28:51Z</dc:date>
    <item>
      <title>Multi-threading in ArcObjects...</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/multi-threading-in-arcobjects/m-p/240721#M6216</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;SPAN&gt;I'm trying to implement multi-threading in my AO code but it fails, after a long wait, with a &lt;/SPAN&gt;&lt;STRONG&gt;RPC_ESERVER Fault&lt;/STRONG&gt;&lt;SPAN&gt; error message.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's how I'm doing it:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Create an ICommand. OnClick calls another method (say Start())&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Start() intantiates the IApplication/IMxDocument and other AO vars and finally creates a Windows form which has a button (say OK) to being processing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;3. When I click OK button, I start another thread, which has all the ArcObjects related processing. The processing is happening with shared variables and some private variables (private to the method). This&amp;nbsp; thread also updates the progress bar.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;With respect to the UI update I understand it should not be happening on the worker thread, but why does the processing take enormous amount of time even for a single selection and then eventually fail.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Nov 2010 05:14:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/multi-threading-in-arcobjects/m-p/240721#M6216</guid>
      <dc:creator>UjjwalNigam</dc:creator>
      <dc:date>2010-11-09T05:14:42Z</dc:date>
    </item>
    <item>
      <title>Re: Multi-threading in ArcObjects...</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/multi-threading-in-arcobjects/m-p/240722#M6217</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm not entirely sure what you are trying to do here but ESRI has some tips for writing multi-threaded code in this article.&lt;/SPAN&gt;&lt;BR /&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;The&lt;/SPAN&gt;&lt;SPAN style="color:Black;"&gt; GeoProcessor.ExecuteAsync is something new that you may be able to make use of.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Nov 2010 15:04:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/multi-threading-in-arcobjects/m-p/240722#M6217</guid>
      <dc:creator>MattMoyles</dc:creator>
      <dc:date>2010-11-09T15:04:19Z</dc:date>
    </item>
    <item>
      <title>Re: Multi-threading in ArcObjects...</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/multi-threading-in-arcobjects/m-p/240723#M6218</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello Matt,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In my application, the background process takes a long time to finish, and during that period the UI freezes (becomes white), hence the need to put the background process on a separate thread, so as to keep the UI responsive and update user about the progress.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've created the thread and everything, but it always fails with the following message:&lt;/SPAN&gt;&lt;BR /&gt;&lt;STRONG&gt;"Attempted to read/write protected memory. This often indicates the memory is corrupt"&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This happens when I'm trying to convert a selection to an interim PGDB...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Nov 2010 02:13:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/multi-threading-in-arcobjects/m-p/240723#M6218</guid>
      <dc:creator>UjjwalNigam</dc:creator>
      <dc:date>2010-11-10T02:13:15Z</dc:date>
    </item>
    <item>
      <title>Re: Multi-threading in ArcObjects...</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/multi-threading-in-arcobjects/m-p/240724#M6219</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Multi-threading is hard and doing it with ArcObjects is harder because of the COM STA model used.&amp;nbsp; Avoid it if you can.&amp;nbsp; In the past when I have searched the forums for this and found very little.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Obviously, you have a memory corruption issue.&amp;nbsp; What you didn't say is what language your code is written in or what exactly your code is doing.&amp;nbsp; For example, C++ is more powerful but also adds risks because there is no VM/CLR.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What is the address of the memory location?&amp;nbsp; It is 0, is it in the OS protected space, it an address that was previously valid and if so what was previously at that address?&amp;nbsp; Debugging these problems gets deep fast.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is the problem yours or ESRI's?&amp;nbsp; Hard to say.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Nov 2010 10:41:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/multi-threading-in-arcobjects/m-p/240724#M6219</guid>
      <dc:creator>RichardWatson</dc:creator>
      <dc:date>2010-11-10T10:41:32Z</dc:date>
    </item>
    <item>
      <title>Re: Multi-threading in ArcObjects...</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/multi-threading-in-arcobjects/m-p/240725#M6220</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hmmm...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I even tried the ESRI suggested way of updating the UI using a delegate...but even that doesn't work!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I really wish if somebody could post the code related to multi-threading...much appreciated!!!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I will keep trying in the meanwhile...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Nov 2010 07:38:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/multi-threading-in-arcobjects/m-p/240725#M6220</guid>
      <dc:creator>UjjwalNigam</dc:creator>
      <dc:date>2010-11-15T07:38:13Z</dc:date>
    </item>
    <item>
      <title>Re: Multi-threading in ArcObjects...</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/multi-threading-in-arcobjects/m-p/240726#M6221</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;OK...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I was able to do it without having a Windows form in the application, but the moment I call the form, I get the following loader lock message:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;"LoaderLock was detected.&lt;BR /&gt;Message: Attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;... and I am unable to proceed further!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried marking the form's Main method as &amp;lt;STAThread()&amp;gt; _, but still the same issue...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;PS: I am working in VB.Net with VS 2005 &amp;amp; ArcGIS 9.2&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Nov 2010 10:28:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/multi-threading-in-arcobjects/m-p/240726#M6221</guid>
      <dc:creator>UjjwalNigam</dc:creator>
      <dc:date>2010-11-16T10:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: Multi-threading in ArcObjects...</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/multi-threading-in-arcobjects/m-p/240727#M6222</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;OK...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I could finally make it working.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am not sure about the AO code being extremely slow in a multi-threading model, as it is discussed in the following ESRI article:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://edndoc.esri.com/arcobjects/9.2/NET/2c2d2655-a208-4902-bf4d-b37a1de120de.htm"&gt;http://edndoc.esri.com/arcobjects/9.2/NET/2c2d2655-a208-4902-bf4d-b37a1de120de.htm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is how I do it:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PS: Names are as per the attached code file. I use VB.Net &amp;amp; VS 2005&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Declare a delegate, a UI update method (&lt;/SPAN&gt;&lt;STRONG&gt;UpdateUI&lt;/STRONG&gt;&lt;SPAN&gt;) and a wrapper method (&lt;/SPAN&gt;&lt;STRONG&gt;UpdateUIWrapper&lt;/STRONG&gt;&lt;SPAN&gt;) to the UI update method in the form class.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Within a module, define a method say &lt;/SPAN&gt;&lt;STRONG&gt;Start&lt;/STRONG&gt;&lt;SPAN&gt;, this mainly instantiates the form; and another "friend" method &lt;/SPAN&gt;&lt;STRONG&gt;UpdateFormUI&lt;/STRONG&gt;&lt;SPAN&gt;, this being the main method for carrying out all the processing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;3. Within the button click method, initialize a new thread, pointing to the &lt;/SPAN&gt;&lt;STRONG&gt;UpdateFormUI&lt;/STRONG&gt;&lt;SPAN&gt; method defined in the module above.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Refer the attached zip for code level details. My form contained a progress bar and a button.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope it helps!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Dec 2010 09:04:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/multi-threading-in-arcobjects/m-p/240727#M6222</guid>
      <dc:creator>UjjwalNigam</dc:creator>
      <dc:date>2010-12-09T09:04:15Z</dc:date>
    </item>
  </channel>
</rss>

