Accepted answer

"the dictionary passed in, is constantly increasing in size"

do you mean that it's being modified while you're executing this code? that's a no-no. i suspect the tolist call is failing due to this. (after tolist() has executed, the list should be effectively separate from the dictionary.)

basically dictionary<tkey, tvalue> doesn't support concurrent reading and writing. you might want to look at concurrentdictionary<,> which allows you to iterate over it while another thread is writing.

one suggestion to improve performance when it's all working: call side.tostring() once at the start of the method, instead of on every single loop iteration.

Related Query

More Query from same tag