Caught: System.ArgumentException: Destination array was not long enough. Check destIndex and length and the array's lower bounds. at System.Array.Copy(Array sourceArray Int32 sourceIndex Array destinationArray Int32 destinationIndex Int32 length Boolean reliable) at System.Collections.Generic.Queue`1.ToArray()
错误:有个ConstantSizedQueue,在转化为Array 试图返回时报错。
原因:多线程中,此Queue在试图转化为Array时,在其他线程中被Enqueue操作了。
对策:lock此Queue对象,然后再进行ToArray操作。