Waiting on dynamic list of promises

0

Hello,

I would like to wait on a list of promises, but the list is dynamically updated (items are added to) by a signal handler.
I tried two approaches - @Wait in the function and waiting on AndPromise. In case of AndPromise - it is a member variable of WF class and gets recreated when a new promise is added to the list by signal handler.

In both cases the function starts execution as soon as the first promise in the list is ready.

How to fix it?

Alex2
已提問 5 年前檢視次數 268 次
1 個回答
0
已接受的答案

Would you clarify your requirements? It looks like that you want to invoke some activity on the first signal and if no new signal is received after the activity is completed just exit the workflow. But if new signals are received while executing the activity then execute them. Correct?

I would just have a queue as a field of the workflow. Then the workflow would read from that queue in a loop (it has to use recursion due to async nature of the code) and exit if it is empty. Then you need another Promise that the workflow function waits on at the beginning until the first signal is received.
In this design you never wait for more than a single Promise at a time.

mfateev
已回答 5 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南