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년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠