public void Wait()
 {
     if (MyThread != null && IsRunning)
     {
         MyThread.Join();
     }
 }