InterlockManager的Monitor()方法产生“集合已修改;可能无法执行枚举操作。”异常。 #1
Labels
No Label
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Sic-Software/Sic.Framework#1
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
10号机RT输出如下日志:
该问题导致的原因
Monitor()
方法已在后台线程中启动执行,而互锁表还未创建完成,CreateInterlockLimit()
方法修改了_dicLimitToActionMap
字典;此时Monitor()正在foreach中遍历该字典,导致抛出此异常。解决方法
Monitor()
中遍历_dicLimitToActionMap
前,先使用ToArray()方法创建KeyValuePair副本。参考:
[1] https://stackoverflow.com/a/3875401/1957479
[2] https://languagelassi.blogspot.com/2014/11/Collection-was-modified-enumeration-operation-may-not-execute.html
[3] https://stackoverflow.com/a/604843