private void bw_DoWork(object sender, DoWorkEventArgs e) { while (!IsPaused && !this.Worker.CancellationPending) { this.IsFinish = false; Stopwatch sw = new Stopwatch(); sw.Start(); GameObjectHelpers.SimulateTurn(); sw.Stop(); long waittime = (int)Settings.GetInstance().GameSpeed - (sw.ElapsedMilliseconds); /* * if ((this.Worker.CancellationPending == true)) * { * e.Cancel = true; * * }*/ if (waittime > 0) { Thread.Sleep((int)waittime); } } this.IsFinish = true; }