What is faster AddRange or Await a task

  • Thread starter Thread starter SalahChafai
  • Start date Start date
S

SalahChafai

Guest
i'm not sure how to explain this but let's say i have a list and each frame new elements are being added to that list, these elements are then used for a process, i want so that if an element is added this frame it will only get used in the next one, there are two ways i can think of to do that:
1-have another list and at the beginning of each frame copy all the elements of the first list to it (using AddRange) so that if an element gets added during the frame it will only get added to the first list and not the second one (the elements of the second one are the ones to be used) and in the next frame the elements added last frame to the first list will get added to the second list and so on
2-when an element asks to be added to the list i run a task that does await NextFrame() and once that task is done i add that element
i'm not sure which approach is faster (take in consideration that there could be about 10 elements added each frame and the list might have about 1000 elements at the same time)

Continue reading...
 
Back
Top