TimerTask interface
تم إرجاعه من DurableClient.createTimer(Date) إذا لم يكن الاستدعاء yield-ed. يمثل مؤقت معلق. راجع الوثائق حول المهام للحصول على مزيد من المعلومات.
يجب إكمال كافة المؤقتات المعلقة أو إلغاؤها حتى يكتمل التنسيق.
المثال
إلغاء عداد الوقت
// 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();
}
- يمتد
الخصائص
| cancel | يشير إلى أنه يجب إلغاء المؤقت. سيتم تنفيذ هذا الطلب على عبارة |
| is |
الخصائص الموروثة
| is |
ما إذا كانت المهمة قد اكتملت أم لا. لاحظ أن الإكمال لا يعادل النجاح. |
| is |
ما إذا كانت المهمة قد أخطأت بطريقة ما بسبب الخطأ. |
| result | نتيجة المهمة، إذا اكتملت. وإلا |
تفاصيل الخاصية
cancel
يشير إلى أنه يجب إلغاء المؤقت. سيتم تنفيذ هذا الطلب على عبارة yield أو return التالية.
cancel: () => void
قيمة الخاصية
() => void
isCanceled
isCanceled: boolean
قيمة الخاصية
boolean
ما إذا كان قد تم إلغاء المؤقت أم لا.
تفاصيل الخاصية الموروثة
isCompleted
ما إذا كانت المهمة قد اكتملت أم لا. لاحظ أن الإكمال لا يعادل النجاح.
isCompleted: boolean
قيمة الخاصية
boolean
موروث منTask.isCompleted
isFaulted
ما إذا كانت المهمة قد أخطأت بطريقة ما بسبب الخطأ.
isFaulted: boolean
قيمة الخاصية
boolean
موروث من مهمة.isFaulted