TimerTask interface
DurableClient から返されます。呼び出しが -ed createTimer(Date)されていない場合にyield します。 保留中のタイマーを表します。 詳細については、タスク に関するドキュメントを参照してください。
オーケストレーションを完了するには、保留中のすべてのタイマーを完了または取り消す必要があります。
例
タイマーを取り消す
// calculate expiration date
const timeoutTask = context.df.createTimer(expirationDate);
// do some work
if (!timeoutTask.isCompleted) {
// An orchestration won't get marked as completed until all its scheduled
// tasks have returned, or been cancelled. Therefore, it is important
// to cancel timers when they're no longer needed
timeoutTask.cancel();
}
例
タイムアウトを作成する
const now = Date.now();
const expiration = new Date(now.valueOf()).setMinutes(now.getMinutes() + 30);
const timeoutTask = context.df.createTimer(expirationDate);
const otherTask = context.df.callActivity("DoWork");
const winner = yield context.df.Task.any([timeoutTask, otherTask]);
if (winner === otherTask) {
// do some more work
}
if (!timeoutTask.isCompleted) {
// An orchestration won't get marked as completed until all its scheduled
// tasks have returned, or been cancelled. Therefore, it is important
// to cancel timers when they're no longer needed
timeoutTask.cancel();
}
- Extends
プロパティ
| cancel | タイマーをキャンセルする必要があることを示します。 この要求は、次の |
| is |
継承されたプロパティ
| is |
タスクが完了したかどうか。 完了は成功と同じではないことに注意してください。 |
| is |
エラーが原因でタスクに何らかのエラーが発生したかどうか。 |
| result | タスクの結果 (完了した場合)。 それ以外の場合は |
プロパティの詳細
cancel
タイマーをキャンセルする必要があることを示します。 この要求は、次の yield または return ステートメントで実行されます。
cancel: () => void
プロパティ値
() => void
isCanceled
isCanceled: boolean
プロパティ値
boolean
タイマーがキャンセルされたかどうか。