【发布时间】:2011-10-23 06:16:32
【问题描述】:
我发现自己曾多次编写过这种类型的代码。
for (int i = 0; i < 10; i++)
{
if (Thing.WaitingFor())
{
break;
}
Thread.Sleep(sleep_time);
}
if(!Thing.WaitingFor())
{
throw new ItDidntHappenException();
}
它只是看起来像糟糕的代码,有没有更好的方法来做到这一点/这是糟糕设计的症状吗?
【问题讨论】:
标签: c# multithreading design-patterns