C#

Moderators: None (Apply to moderate this forum)
Number of threads: 2720
Number of posts: 5746

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Unmanaged Code Posted by suburbanmt on 13 Feb 2006 at 7:26 AM
Hi,

I have a linked list which is built using unmanaged code. Is there a way in which I can store a non-primitive object such as a class instance? What i want is to be able to store an instance of Class1 for example in the list and than read the instance from the list.

Thanks
Report
Re: Unmanaged Code Posted by tsagld on 13 Feb 2006 at 8:02 AM
I am not sure there is a way, but if there were, it is probably extremely dangerous. So there probably isn't.
The thing is that the Framework cannot keep track of references stored in unmanaged code. So there is a great risk that the Framework's garbage collector destroys the instance of your class while your unmanaged linked list still holds a reference to it.
Reading the instance back from the list and using it will then result in disaster.


: Hi,
:
: I have a linked list which is built using unmanaged code. Is there a way in which I can store a non-primitive object such as a class instance? What i want is to be able to store an instance of Class1 for example in the list and than read the instance from the list.
:
: Thanks
:


Greets,
Eric Goldstein
www.gvh-maatwerk.nl

Report
Re: Unmanaged Code Posted by suburbanmt on 13 Feb 2006 at 11:05 AM
This message was edited by suburbanmt at 2006-2-13 11:5:33

The problem is that the application i'm developing is quite dependent on performance, so using an arraylist for the job wouldn't be that efficient. Do you have any suggestions regarding any other available data structures?

Thanks for your help


: I am not sure there is a way, but if there were, it is probably extremely dangerous. So there probably isn't.
: The thing is that the Framework cannot keep track of references stored in unmanaged code. So there is a great risk that the Framework's garbage collector destroys the instance of your class while your unmanaged linked list still holds a reference to it.
: Reading the instance back from the list and using it will then result in disaster.
:
:
: : Hi,
: :
: : I have a linked list which is built using unmanaged code. Is there a way in which I can store a non-primitive object such as a class instance? What i want is to be able to store an instance of Class1 for example in the list and than read the instance from the list.
: :
: : Thanks
: :
:
:
: Greets,
: Eric Goldstein
: www.gvh-maatwerk.nl
:
:



Report
Re: Unmanaged Code Posted by iwilld0it on 13 Feb 2006 at 2:35 PM
Report
Re: Unmanaged Code Posted by suburbanmt on 14 Feb 2006 at 1:43 AM
Tx, my problem is that the type is unknown as it is dynamic so I want the objects stored as OBJECT so that I can typecast them when I retrieve them from the list. What I want to do is as follows :

1) I have an object of unknown type

2) Store it in linked list (unmanaged code)

3) Retrieve it from the list and type cast it



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.