湖边的白杨树

探索是一种乐趣

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

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操作。

posted on 2013-06-03 17:47  fdyang  阅读(2521)  评论(0编辑  收藏  举报