public double sleep;//线程休眠时间
/// <summary>
/// 线程休眠
/// </summary>
/// <param name="sleep">休眠时间,以毫秒为单位</param>
private void WaitDelayTime(double sleep)
{
Stopwatch sw = Stopwatch.StartNew();
sw.Restart();
while (true)
{
try
{
Thread.Sleep(2);
bool flag = (double)sw.ElapsedMilliseconds >= sleep;
if (flag)
{
goto block;
}
}
catch (Exception ex)
{
}
}
block:
return;
}
C# Thread.Sleep替代方法
最新推荐文章于 2023-09-05 20:28:06 发布