示例#1
0
        //
        // Starts the test.
        //

        internal static Action Run()
        {
            for (int i = 0; i < EVENTS; i++)
            {
                es[i] = new StSynchronizationEvent(false, 200);
            }
            for (int i = 0; i < ACQUIRERS; i++)
            {
                new Acquirer().Start(i, "a #" + i);
            }
            for (int i = 0; i < RELEASERS; i++)
            {
                new Releaser().Start(i, "r #" + i);
            }
            Action stop = () => {
                shutdown.Set();
                done.WaitOne();
                long rels = 0;
                for (int i = 0; i < RELEASERS; i++)
                {
                    rels += releases[i];
                }
                long acqs = 0;
                for (int i = 0; i < ACQUIRERS; i++)
                {
                    acqs += acquires[i];
                }

                VConsole.WriteLine("+++ Total: rels = {0}, acqs = {1}, smash = {2}",
                                   rels, acqs, smashed);
            };

            return(stop);
        }
        //
        // Starts the test.
        //

		internal static Action Run() {
			for (int i = 0; i < EVENTS; i++) {
				es[i] = new StSynchronizationEvent(false, 200);
			}
			for (int i = 0; i < ACQUIRERS; i++) {
				new Acquirer().Start(i, "a #" + i);
			}
			for (int i = 0; i < RELEASERS; i++) {
				new Releaser().Start(i, "r #" + i);
			}
            Action stop = () => {
                shutdown.Set();
                done.WaitOne();
			    long rels = 0;
			    for (int i = 0; i < RELEASERS; i++) {
				    rels += releases[i];
			    }
			    long acqs = 0;
			    for (int i = 0; i < ACQUIRERS; i++) {
				    acqs += acquires[i];
			    }

			    VConsole.WriteLine("+++ Total: rels = {0}, acqs = {1}, smash = {2}",
                                    rels, acqs, smashed);
            };
            return stop;
		}