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

相关文章:

  • 2021-12-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-15
  • 2021-11-03
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-30
  • 2022-12-23
  • 2022-01-14
相关资源
相似解决方案