コード例 #1
0
    static int Main()
    {
        // warning CS0197 is expected several times

        UnlockedCbo uc = new UnlockedCbo();

        Interlocked.Increment(ref uc.Counter);
        uc.Inc();

        LockedCbo lc = new LockedCbo();

        try
        {
            Interlocked.Increment(ref lc.Counter);
            return(1);
        }
        catch (InvalidOperationException)
        {
        }

        lc.Inc();

        if (lc.Counter != 1)
        {
            return(2);
        }

        Mbr m = new Mbr();

        Interlocked.Increment(ref m.Counter);
        m.Inc();

        if (m.Counter != 2)
        {
            return(3);
        }

        Mbr rm = (Mbr)CreateRemote(typeof(Mbr));

        try
        {
            Interlocked.Increment(ref rm.Counter);
            return(4);
        }
        catch (InvalidOperationException)
        {
        }

        rm.Inc();

        if (rm.Counter != 1)
        {
            return(5);
        }

        return(0);
    }
コード例 #2
0
ファイル: bug-415577.cs プロジェクト: Zman0169/mono
	static int Main ()
	{
		// warning CS0197 is expected several times
		
		UnlockedCbo uc = new UnlockedCbo ();
		Interlocked.Increment (ref uc.Counter);
		uc.Inc ();

		LockedCbo lc = new LockedCbo ();
		try {
			Interlocked.Increment (ref lc.Counter);
			return 1;
		} catch (InvalidOperationException) {
		}

		lc.Inc ();

		if (lc.Counter != 1)
			return 2;

		Mbr m = new Mbr ();
		Interlocked.Increment (ref m.Counter);
		m.Inc ();

		if (m.Counter != 2)
			return 3;

		Mbr rm = (Mbr) CreateRemote (typeof (Mbr));
		try {
			Interlocked.Increment (ref rm.Counter);
			return 4;
		} catch (InvalidOperationException) {
		}

		rm.Inc ();

		if (rm.Counter != 1)
			return 5;

		return 0;
	}
コード例 #3
0
ファイル: bug-415577.cs プロジェクト: mdae/MonoRT
    static int Main()
    {
        // warning CS0197 is expected several times

        UnlockedCbo uc = new UnlockedCbo();

        Interlocked.Increment(ref uc.Counter);
        uc.Inc();
        //
        //  Beginn Aenderung Test
        //
        Console.WriteLine("\n\t****C#: VOR LockedCbo lc = new LockedCbo () ****\n");
        //
        //  Ende Aenderung Test
        //
        LockedCbo lc = new LockedCbo();

        //
        //  Beginn Aenderung Test
        //
        Console.WriteLine("\n\t****C#: NACH LockedCbo lc = new LockedCbo () ****\n");
        //
        //  Ende Aenderung Test
        //
        try {
            //
            //  Beginn Aenderung Test
            //
            Console.WriteLine("\n\t****C#: VOR Interlocked.Increment (ref lc.Counter) ****\n");
            //
            //  Ende Aenderung Test
            //
            Interlocked.Increment(ref lc.Counter);
            return(1);
        } catch (InvalidOperationException e) {
            //
            //  Beginn Aenderung Test
            //
            Console.WriteLine(e.ToString());
            //
            //  Ende Aenderung Test
            //
        }

        lc.Inc();

        if (lc.Counter != 1)
        {
            return(2);
        }

        Mbr m = new Mbr();

        Interlocked.Increment(ref m.Counter);
        m.Inc();

        if (m.Counter != 2)
        {
            return(3);
        }

        Mbr rm = (Mbr)CreateRemote(typeof(Mbr));

        try {
            Interlocked.Increment(ref rm.Counter);
            return(4);
        } catch (InvalidOperationException) {
        }

        rm.Inc();

        if (rm.Counter != 1)
        {
            return(5);
        }

        return(0);
    }