<PackageReference Include="NUnit" Version="3.0.0-alpha" />

SimpleWorkItemDispatcher

SimpleWorkItemDispatcher handles execution of WorkItems by directly executing them. It is provided so that a dispatcher is always available in the context, thereby simplifying the code needed to run child tests.
using System.Threading; namespace NUnit.Framework.Internal.Execution { public class SimpleWorkItemDispatcher : IWorkItemDispatcher { private WorkItem _topLevelWorkItem; private Thread _runnerThread; public void Dispatch(WorkItem work) { if (_topLevelWorkItem != null) work.Execute(); else { _topLevelWorkItem = work; _runnerThread = new Thread(RunnerThreadProc); _runnerThread.Start(); } } private void RunnerThreadProc() { _topLevelWorkItem.Execute(); } public void CancelRun() { if (_runnerThread != null && _runnerThread.IsAlive) ThreadUtility.Kill(_runnerThread); } } }