static void WaitSometingProc(object LockWatingThread) { while (true) { Thread.Sleep(waitStep); lock (LockWatingThread) { if (bGenerateSometing) { return; } if (waitCount == 0) { bWaitTimeOut = true; return; } waitCount--; wp.SetProcessBarPerformStep(); } } }