次の方法で共有


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

タイマーをキャンセルする必要があることを示します。 この要求は、次の yield または return ステートメントで実行されます。

isCanceled

継承されたプロパティ

isCompleted

タスクが完了したかどうか。 完了は成功と同じではないことに注意してください。

isFaulted

エラーが原因でタスクに何らかのエラーが発生したかどうか。

result

タスクの結果 (完了した場合)。 それ以外の場合は undefined

プロパティの詳細

cancel

タイマーをキャンセルする必要があることを示します。 この要求は、次の yield または return ステートメントで実行されます。

cancel: () => void

プロパティ値

() => void

isCanceled

isCanceled: boolean

プロパティ値

boolean

タイマーがキャンセルされたかどうか。

継承されたプロパティの詳細

isCompleted

タスクが完了したかどうか。 完了は成功と同じではないことに注意してください。

isCompleted: boolean

プロパティ値

boolean

承元Task.isCompleted

isFaulted

エラーが原因でタスクに何らかのエラーが発生したかどうか。

isFaulted: boolean

プロパティ値

boolean

Task.isFaultedから継承

result

タスクの結果 (完了した場合)。 それ以外の場合は undefined

result?: unknown

プロパティ値

unknown

承元Task.result