<?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: Using for LayerTableRecord(LTR) in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/using-for-layertablerecord-ltr/m-p/8986963#M21460</link>
    <description>&lt;P&gt;OK, the confusion, to me, was that I am using 2 different docos 1 from AutoCAD and the other from BricsCAD.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DBObject is derived from Drawable in AC and DisposableWrapper in BricsCAD which implements IDisposable. 'using' construct also calls the dispose meth of the resource created in the header IF it has one, however in AC there is no Dispose meth for DBobjects nor for its derivatives. that's is the confusion for me and wondering about ref counts!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sorry mate!&lt;/P&gt;</description>
    <pubDate>Mon, 26 Aug 2019 08:03:27 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-08-26T08:03:27Z</dc:date>
    <item>
      <title>Using for LayerTableRecord(LTR)</title>
      <link>https://forums.autodesk.com/t5/net-forum/using-for-layertablerecord-ltr/m-p/8986522#M21456</link>
      <description>&lt;P&gt;Please take a look athe C# sample &lt;A href="http://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-31193942-2AEB-4BFF-A861-6279EE8394A2" target="_blank" rel="noopener"&gt;here&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The LTR gets disposed before the transaction is commited and is that correct? I have not tested the code myself as I have only Inventore development setup.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not sure if the DBObject.Dispose actually disposes the resources or decreses the ref count..&lt;/P&gt;</description>
      <pubDate>Sun, 25 Aug 2019 23:16:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/using-for-layertablerecord-ltr/m-p/8986522#M21456</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-08-25T23:16:14Z</dc:date>
    </item>
    <item>
      <title>Re: Using for LayerTableRecord(LTR)</title>
      <link>https://forums.autodesk.com/t5/net-forum/using-for-layertablerecord-ltr/m-p/8986792#M21457</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes, it's correct.&lt;/P&gt;
&lt;P&gt;Wrapping newly created DBObjects in a using statement, is a practice to insure the DBObject will be disposed in case an error occurs before the DBObject is added to the Transaction*, as soon as the DBObject is added to the Transaction, disposing the Transaction will take care of the disposing the DBObject.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;* IMO, this is useless in this sample (none error can occur). The Test1() and Test2() methods in this recent reply shows this.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Aug 2019 05:57:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/using-for-layertablerecord-ltr/m-p/8986792#M21457</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2019-08-26T05:57:50Z</dc:date>
    </item>
    <item>
      <title>Re: Using for LayerTableRecord(LTR)</title>
      <link>https://forums.autodesk.com/t5/net-forum/using-for-layertablerecord-ltr/m-p/8986858#M21458</link>
      <description>&lt;P&gt;Yeah i get it the reference count for the DBObject doesnt reach zero until after the transaction goes out of scope.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so what do you do if you have to create say 10 dbobjects to construct something to ensure the stack rolls back?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;using (var p1=new Line())&lt;/P&gt;&lt;P&gt;using(var c1=new Line))&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;using(var o10=new Entity())&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;?&lt;/P&gt;</description>
      <pubDate>Mon, 26 Aug 2019 06:54:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/using-for-layertablerecord-ltr/m-p/8986858#M21458</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-08-26T06:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: Using for LayerTableRecord(LTR)</title>
      <link>https://forums.autodesk.com/t5/net-forum/using-for-layertablerecord-ltr/m-p/8986910#M21459</link>
      <description>&lt;P&gt;As I try to explain, if an error or user break may occur after a DBObject is created and before it is added to the transaction, do use a using statement, if none error can occur (as in the sample you linked), the using statement is not mandatory, and this, whatever the number of DBObject you create.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS: I forgot the link in my last message, it would have been:&lt;/P&gt;
&lt;P&gt;* IMO, this is useless in this sample (none error can occur). The Test1() and Test2() methods in &lt;A href="https://forums.autodesk.com/t5/net/dispose-mleader-and-it-s-mtext-in-jig/m-p/8984499/highlight/true#M63574" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;this recent reply&lt;/STRONG&gt;&lt;/A&gt; shows this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Aug 2019 07:25:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/using-for-layertablerecord-ltr/m-p/8986910#M21459</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2019-08-26T07:25:44Z</dc:date>
    </item>
    <item>
      <title>Re: Using for LayerTableRecord(LTR)</title>
      <link>https://forums.autodesk.com/t5/net-forum/using-for-layertablerecord-ltr/m-p/8986963#M21460</link>
      <description>&lt;P&gt;OK, the confusion, to me, was that I am using 2 different docos 1 from AutoCAD and the other from BricsCAD.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DBObject is derived from Drawable in AC and DisposableWrapper in BricsCAD which implements IDisposable. 'using' construct also calls the dispose meth of the resource created in the header IF it has one, however in AC there is no Dispose meth for DBobjects nor for its derivatives. that's is the confusion for me and wondering about ref counts!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sorry mate!&lt;/P&gt;</description>
      <pubDate>Mon, 26 Aug 2019 08:03:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/using-for-layertablerecord-ltr/m-p/8986963#M21460</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-08-26T08:03:27Z</dc:date>
    </item>
    <item>
      <title>Re: Using for LayerTableRecord(LTR)</title>
      <link>https://forums.autodesk.com/t5/net-forum/using-for-layertablerecord-ltr/m-p/8987000#M21461</link>
      <description>&lt;P&gt;In AutoCAD, Drawable is derived from RXObject which is derived from DisposableWrapper, so, DBObject and derived classes do have a Dispose() method.&lt;/P&gt;
&lt;P&gt;You can read &lt;A href="https://www.theswamp.org/index.php?topic=42399.0" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;this topic&lt;/STRONG&gt;&lt;/A&gt; at TheSwamp and pay attention to Tony "theMaster" Tanzillo advices.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Aug 2019 08:24:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/using-for-layertablerecord-ltr/m-p/8987000#M21461</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2019-08-26T08:24:02Z</dc:date>
    </item>
    <item>
      <title>Re: Using for LayerTableRecord(LTR)</title>
      <link>https://forums.autodesk.com/t5/net-forum/using-for-layertablerecord-ltr/m-p/8987026#M21462</link>
      <description>&lt;P&gt;Thanks for that!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Aug 2019 08:45:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/using-for-layertablerecord-ltr/m-p/8987026#M21462</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-08-26T08:45:16Z</dc:date>
    </item>
    <item>
      <title>Re: Using for LayerTableRecord(LTR)</title>
      <link>https://forums.autodesk.com/t5/net-forum/using-for-layertablerecord-ltr/m-p/8987091#M21463</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;When we write managed code, we are &lt;EM&gt;&lt;STRONG&gt;always&lt;/STRONG&gt;&lt;/EM&gt; relying on the GC to clean up the managed objects we create and use (whether they implement IDisposable or not), and we do not need to be concerned with deallocating those objects or the memory they consume, calling d'tors, etc.&lt;/BLOCKQUOTE&gt;&lt;P&gt;The comment on GC from the master is inaccurate.&lt;/P&gt;&lt;P&gt;Actually, GC only frees the resources that have reached the zero count. objects implementing IDisposable have to release their own resources and even then when they are released (through Dispose meth) only the ref count is descresed on that reference and ultimately the GC that actually frees the resources.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the Test2 in the code you cited uses Erase method to mark it, not releasing the resource. when Circle was created with the new operator its ref count would have been bumped up and everytime it is on the right side of the assignment operator.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;what is not clear to me is whether the transaction object adds ref count or not when the Add() meth is called and does it release the ref count for Erase() marked objects. in C++ when a COM interface passed to a func a ref is added?&lt;BR /&gt;&lt;BR /&gt;One way to find that out is by allocating a large number of objects and then testing with diag tools.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Aug 2019 09:17:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/using-for-layertablerecord-ltr/m-p/8987091#M21463</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-08-26T09:17:05Z</dc:date>
    </item>
    <item>
      <title>Re: Using for LayerTableRecord(LTR)</title>
      <link>https://forums.autodesk.com/t5/net-forum/using-for-layertablerecord-ltr/m-p/8987149#M21464</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous&amp;nbsp;wrote:&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;the Test2 in the code you cited uses Erase method to mark it, not releasing the resource. when Circle was created with the new operator its ref count would have been bumped up and everytime it is on the right side of the assignment operator.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Releasing the resources of the Circle has nothing to do with the Erase() functions the Circle is disposed when the Transaction is disposed because it have been added to the Transaction with the AddNewlyCreatedDBObject() method. This way, the circle is treated as any DBObject opened with the Transaction.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Aug 2019 09:42:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/using-for-layertablerecord-ltr/m-p/8987149#M21464</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2019-08-26T09:42:41Z</dc:date>
    </item>
    <item>
      <title>Re: Using for LayerTableRecord(LTR)</title>
      <link>https://forums.autodesk.com/t5/net-forum/using-for-layertablerecord-ltr/m-p/8987184#M21465</link>
      <description>&lt;P&gt;according to the doco the Erase method sets the erase bit, so is it for some other purpose?&lt;BR /&gt;&lt;BR /&gt;&amp;gt;&amp;gt; AddNewlyCreatedDBObject() method. This way, the circle is treated as any DBObject opened with the Transaction.&lt;/P&gt;&lt;P&gt;I see what you mean, thanks!!&lt;/P&gt;</description>
      <pubDate>Mon, 26 Aug 2019 09:56:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/using-for-layertablerecord-ltr/m-p/8987184#M21465</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-08-26T09:56:30Z</dc:date>
    </item>
  </channel>
</rss>

