问题描述
我已经使用多个线程之间共享的静态全局数据集。
我有以下异常:
在线程,我读的数据表和安培值;更新(用于合并)的线程进行数据表中的两个操作的价值。
您正在做的从不同的线程数据集的操作。
该数据集不是线程安全的,你应该做一个包装类
可以保护数据集从超过1操作的时间。这就是所谓的互斥:
微软MSDN 链接P>
一个更好的解决方案是没有用的全局状态可言。这将解决您的问题,没有任何额外的工作,让您的code更可靠。
I have used a static Global dataset shared between a number of threads.
I got the following exception :
In threading, I read the value from the datatable & update(used merge) the value in datatable both operation done in threading.
You are doing operations on a dataset from different threads.
The dataset is not thread safe, you should make a wrapper class
which protects the dataset from more than 1 operation at the time. This is called a mutex:
A better solution is to no use global state at all. This will fix your problem without any extra work and makes your code much more reliable.
这篇关于数据表的内部索引已损坏:“5'.used在穿线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!