C Board  

Go Back   C Board > General Programming Boards > C# Programming

Closed Thread
 
LinkBack Thread Tools Display Modes
Old 04-19-2008, 05:13 AM   #1
Registered User
 
Join Date: May 2006
Posts: 1,579
object destroy

Hello everyone,


Two questions about the following code,

1. When instance of Class1 is put to GC queue, its wrapped Obj instance is 100% ensured to move to GC queue, but the order of whether the memory and Finalize method of Class1 instance or obj1 instance will be called first can not be decided (GC may make different decision in different situations)?

2. If some instance does not hold the reference of Class1, but holds the reference to obj1 through public method PassOut, in this situation, Class1 instance is prevent from being GCed?

Code:
using System;

/// <summary>
/// Summary description for Class1
/// </summary>
public class Class1
{
    private Component Obj = new Component();

    public Component PassOut()
    {
        return Obj;
    }

    public Class1()
	{
        //
		// TODO: Add constructor logic here
		//
	}
}

thanks in advance,
George
George2 is offline  
Closed Thread

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Object destroy itself? cminusminus C++ Programming 28 03-27-2008 01:08 AM
using this as synchronization object George2 C# Programming 0 03-22-2008 07:49 AM
circular doubly linked list help gunnerz C++ Programming 5 04-28-2007 08:38 PM
Question on l-values. Hulag C++ Programming 6 10-13-2005 04:33 PM
A question about constructors... Wolve C++ Programming 9 05-04-2005 04:24 PM


All times are GMT -6. The time now is 08:58 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22