.NET

Reply
*perry
Message 1 of 5 (72 Views)

A question on C# classes for Acad

72 Views, 4 Replies
10-31-2006 03:27 PM
In an app I'm working on I have several (non static) classed defined.
A couple of these, lets call them CLASS-A and CLASS-B deal with
particular types of blocks.
During the course of my apps life, its likely these classes will be
instantiated more than once. What can happen then is I may have several
objects of CLASS-A which may be associated with the same block
reference. This is not the type of behavior I want. With C++ this wasn't
an issue because I'd delete the object after using it, not so with C#.
So how could I go about creating an object only if it does not already
exist or is not associated with a block ref that is already being "watched"?
I would not think that making these classes "disposable" would help.
Calling dispose is not like deleting in C++, the object will still be in
memory and still accessible.
Make the class Static and just have its methods reference a different
block each time its called, depending on circumstances?
Thanks for any tips.
Perry
*perry
Message 2 of 5 (72 Views)

Re: A question on C# classes for Acad

10-31-2006 03:34 PM in reply to: *perry
Another option:
Make the class abstract (like the docdata class in the jig example)
and implement in it a hashtable and have this abstract version
instantiate a concrete version only if there is not one in the hashtable.?
*J. Daniel Smith
Message 3 of 5 (72 Views)

Re: A question on C# classes for Acad

11-01-2006 06:43 AM in reply to: *perry
.NET IDisposable interface does a portion of C++'s "delete", namely the
deallocation of resources (of course in .NET, the GC handles the actual
free() to release memory). Once an object has been Dispose()'d, it really
shouldn't be used anymore; you can make your methods throw an
ObjectDisposedException.

Dan

"perry" wrote in message
news:5380800@discussion.autodesk.com...
In an app I'm working on I have several (non static) classed defined.
A couple of these, lets call them CLASS-A and CLASS-B deal with
particular types of blocks.
During the course of my apps life, its likely these classes will be
instantiated more than once. What can happen then is I may have several
objects of CLASS-A which may be associated with the same block
reference. This is not the type of behavior I want. With C++ this wasn't
an issue because I'd delete the object after using it, not so with C#.
So how could I go about creating an object only if it does not already
exist or is not associated with a block ref that is already being "watched"?
I would not think that making these classes "disposable" would help.
Calling dispose is not like deleting in C++, the object will still be in
memory and still accessible.
Make the class Static and just have its methods reference a different
block each time its called, depending on circumstances?
Thanks for any tips.
Perry
*perry
Message 4 of 5 (72 Views)

Re: A question on C# classes for Acad

11-02-2006 07:53 AM in reply to: *perry
J. Daniel Smith wrote:
> .NET IDisposable interface does a portion of C++'s "delete", namely the
> deallocation of resources (of course in .NET, the GC handles the actual
> free() to release memory). Once an object has been Dispose()'d, it really
> shouldn't be used anymore; you can make your methods throw an
> ObjectDisposedException.
>
> Dan
>
Yes, I have read that.
Still looking for input on the original question.
I tried making the classes in question static, which
of course means I don't have any redundant objects but
that raises other issues to deal with.
Perhaps the abstract class idea is the best but I'm still
trying to understand just how the "docdata" classes
(in the palette sample) work.
Perry
*perry
Message 5 of 5 (72 Views)

Re: A question on C# classes for Acad

11-06-2006 02:36 PM in reply to: *perry
I guess this has never been an issue for anyone eh?
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.