c# Dictionary线程冲突问题解决

错误信息:

InvalidOperationException: Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct.

dictionary数据类型是非线程安全的,并发访问同一个内容字典会抛并发冲突

解决:

Dictionary换成ConCurrentDictionary,线程安全

你可能感兴趣的:(.Net日常工作问题)