예제 #1
0
        private void RunTest(Action action, CancellationToken cancellationToken)
        {
            _readyForCancellation = _caughtException = _finishedExecution = false;
            _exception            = null;
            _counter = 0;

            try
            {
                ControlledExecution.Run(action, cancellationToken);
            }
            catch (Exception e)
            {
                _exception = e;
            }
        }
예제 #2
0
        public void TestNestedRunInvocation()
        {
            bool nestedExecution = false;

            var cts = new CancellationTokenSource();

            RunTest(Test, cts.Token);

            Assert.False(nestedExecution);
            Assert.IsType <InvalidOperationException>(_exception);

            void Test()
            {
                ControlledExecution.Run(() => nestedExecution = true, cts.Token);
            }
        }