public void ShouldHandleManagedThreads()
        {
            var counter = 0;
            var a       = (Action)(() => counter++);

            using (var emulation = new Emulation())
            {
                var machine = new Machine();

                emulation.MasterTimeSource.Quantum            = Time.TimeInterval.FromMilliseconds(1000);
                emulation.MasterTimeSource.AdvanceImmediately = true;
                machine.LocalTimeSource.Quantum            = Time.TimeInterval.FromMilliseconds(1000);
                machine.LocalTimeSource.AdvanceImmediately = true;

                emulation.AddMachine(machine);

                var mt = machine.ObtainManagedThread(a, 1);

                emulation.RunToNearestSyncPoint();
                emulation.RunToNearestSyncPoint();
                emulation.RunToNearestSyncPoint();
                Assert.AreEqual(0, counter);

                mt.Start();

                emulation.RunToNearestSyncPoint();
                Assert.AreEqual(1, counter);

                emulation.RunToNearestSyncPoint();
                Assert.AreEqual(2, counter);

                emulation.RunToNearestSyncPoint();
                Assert.AreEqual(3, counter);

                mt.Stop();

                emulation.RunToNearestSyncPoint();
                emulation.RunToNearestSyncPoint();
                emulation.RunToNearestSyncPoint();
                Assert.AreEqual(3, counter);
            }
        }