예제 #1
0
        protected void Start()
        {
            var currState = Volatile.Read(ref v_executionState);

            if (currState > NotStartedState)
            {
                ThrowHelper.ThrowInvalidOperationException_ExecutionState(currState);
            }
            _thread.Start(this);
        }
예제 #2
0
        public static long Run()
        {
            long      ran        = 0;
            const int Iterations = 100 * 1000 * 1000;

            Thread thread = null;

            thread = new Thread(() =>
            {
                CodeTimer.Time(true, "Thread", Iterations, () =>
                {
                    if (Thread.CurrentThread == thread)
                    {
                        ran++;
                    }
                });
            });
            thread.Start();
            thread.Join(100000);

            XThread xthread = null;

            xthread = new XThread(() =>
            {
                CodeTimer.Time(true, "XThread", Iterations, () =>
                {
                    if (XThread.CurrentThread == xthread)
                    {
                        ran++;
                    }
                });
            });
            xthread.Start();
            xthread.Join(100000);

            return(ran);
        }