public void Yield()
 {
     if (MyThread.Store(0) == 0)
     {
         MainThread.Restore(1);
     }
 }
 public void DoWork(Action action)
 {
     if (MainThread.Store(0) == 0)
     {
         action();
         Done = true;
         MainThread.Restore(1);
     }
 }