public void FailSomeWhere()
        {
            Console.WriteLine("started");
            using (var thread = new StopAndGoThread())
            {
                Console.WriteLine("thread.Run");

                thread.Run(() => { throw new Exception("X"); });
            }
        }
 public void TestRunOneThing()
 {
     Console.WriteLine("started");
     using (var thread = new StopAndGoThread())
     {
         Console.WriteLine("thread.Run");
         bool ran = false;
         thread.Run(() =>
                        {
                            ran = true;
                            Console.WriteLine("running");
                        });
         Assert.IsTrue(ran);
         Console.WriteLine("thread.Dispose()");
     }
     Console.WriteLine("done");
 }
        public void TestRunTwoThingsAsync()
        {
            Console.WriteLine("started");
            bool ranSecond = false;
            bool ranFirst = false;

            using (var thread = new StopAndGoThread())
            {
                Console.WriteLine("thread.Run");
                var st = new Stopwatch();
                st.Start();
                thread.RunAsync(() =>
                                    {
                                        Console.WriteLine("running");
                                        Thread.Sleep(50);
                                        Console.WriteLine("done 1 " + st.ElapsedMilliseconds + "ms");
                                        ranFirst = true;
                                    });

                Console.WriteLine("queue 2 " + st.ElapsedMilliseconds + "ms");

                thread.RunAsync(() =>
                                    {
                                        Console.WriteLine("running second time");
                                        Console.WriteLine("done 2 " + st.ElapsedMilliseconds + "ms");
                                        ranSecond = true;
                                    });

                Console.WriteLine("thread.Dispose()");
            }
            Assert.IsTrue(ranFirst);
            Assert.IsTrue(ranSecond);
            Console.WriteLine("done");
        }