예제 #1
0
    public static int  Main()
    {
        int      returnValue = 0;
        Dummy    obj         = new Dummy();
        StrDummy strobj      = new StrDummy(999);
        Color    enumobj     = new Color();

        GC.Collect();
        GC.WaitForPendingFinalizers();


        if ((Dummy.visited == false) && (StrDummy.flag == true))         // has not visited the Finalize()
        {
            returnValue = 100;
            Console.WriteLine("Test passed!");
        }
        else
        {
            returnValue = 1;
            Console.WriteLine("Test failed!");
        }

        GC.KeepAlive(obj);              // will keep alive 'obj' till this point
        GC.KeepAlive(1000000);
        GC.KeepAlive("long string for testing");
        GC.KeepAlive(-12345678);
        GC.KeepAlive(3456.8989);
        GC.KeepAlive(true);
        GC.KeepAlive(strobj);
        GC.KeepAlive(enumobj);

        return(returnValue);
    }
예제 #2
0
	public static int  Main() {

        int returnValue = 0;
		Dummy obj = new Dummy();
		StrDummy strobj = new StrDummy(999);
		Color enumobj = new Color();
	
		GC.Collect();
		GC.WaitForPendingFinalizers();
		
			
		if((Dummy.visited == false) && (StrDummy.flag==true)) {  // has not visited the Finalize()
            returnValue = 100;
			Console.WriteLine("Test passed!");
		}
		else {
            returnValue = 1;
			Console.WriteLine("Test failed!");
		}

		GC.KeepAlive(obj);	// will keep alive 'obj' till this point
		GC.KeepAlive(1000000);
		GC.KeepAlive("long string for testing");
		GC.KeepAlive(-12345678);
		GC.KeepAlive(3456.8989);
		GC.KeepAlive(true);
		GC.KeepAlive(strobj);
		GC.KeepAlive(enumobj);

        return returnValue;
		
	}