特定の条件が満たされるまで、2分ごとにコードアクティビティを繰り返すための最良の方法は何ですか?
データベースをチェックしてレポートのバッチが完了したことを確認する次のコードアクティビティがあるとします。
public sealed class CheckReportsAreComplete : CodeActivity
{
public InArgument<int> ReportBatchId{ get; set; }
public OutArgument<bool> HaveReportsCompleted{ get; set; }
protected override void Execute(CodeActivityContext context)
{
bool haveCompleted = ReportService.HaveReportsCompleted((context.GetValue(this.ReportBatchId));
HaveReportsCompleted.Set(context, haveCompleted);
}
}
このコードアクティビティを2分ごとに実行し、OutArgumentHaveReportsCompletedがtrueに設定されているときに処理を続行する必要があります。コードでTimer.Sleepを使用する必要がありますか、それとも悪い習慣ですか?
遅延と状態を伴うwhile/doの組み合わせが必要だと思いますか?