private void ExecuteTestStep(BizUnitTestStepWrapper stepWrapper, TestStage stage) { try { // Should this step be executed concurrently? if (stepWrapper.RunConcurrently) { _logger.TestStepStart(stepWrapper.TypeName, DateTime.Now, true, stepWrapper.FailOnError); Interlocked.Increment(ref _inflightQueueDepth); ThreadPool.QueueUserWorkItem(new WaitCallback(WorkerThreadThunk), new ConcurrentTestStepWrapper(stepWrapper, _context)); } else { _logger.TestStepStart(stepWrapper.TypeName, DateTime.Now, false, stepWrapper.FailOnError); stepWrapper.Execute(_context); } } catch (Exception e) { _logger.TestStepEnd(stepWrapper.TypeName, DateTime.Now, e); if (stepWrapper.FailOnError) { if (e is ValidationStepExecutionException) { throw; } else { var tsee = new TestStepExecutionException("BizUnit encountered an error executing a test step", e, stage, _testName, stepWrapper.TypeName); throw tsee; } } } if (!stepWrapper.RunConcurrently) { _logger.TestStepEnd(stepWrapper.TypeName, DateTime.Now, null); } FlushConcurrentQueue(false, stage); }