As you know the RBrokerListenerManagermethod, which handles task result, iterates m_liveTaskTokensqueue by task token. If current task is done, it invokes onTaskCompletedfor this task and removes a task from head of the m_liveTaskTokens queue. This logic works fine while all tasks are done or were executed in single thread or one by one. But once one of tasks is not done, this task continue to be the first to out and will be removed from the queue with next completed task. Consequently some of task would not be notified as completed and some would be handled twice or more times.
So using for this case a queue is definitely wrong approach. Please replace ConcurrentBag<RTaskToken>with a ConcurrentDictionary<RTaskToken, RTask>, which supports direct remove a particular instance.
Hi! It's me again.
As you know the
RBrokerListenerManager
method, which handles task result, iteratesm_liveTaskTokens
queue by task token. If current task is done, it invokesonTaskCompleted
for this task and removes a task from head of the m_liveTaskTokens queue. This logic works fine while all tasks are done or were executed in single thread or one by one. But once one of tasks is not done, this task continue to be the first to out and will be removed from the queue with next completed task. Consequently some of task would not be notified as completed and some would be handled twice or more times. So using for this case a queue is definitely wrong approach. Please replaceConcurrentBag<RTaskToken>
with aConcurrentDictionary<RTaskToken, RTask>
, which supports direct remove a particular instance.Cheers!