数据表的内部索引已损坏:“5'.used在穿线 [英] DataTable internal index is corrupted: '5'.used in threading

查看:173
本文介绍了数据表的内部索引已损坏:“5'.used在穿线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用多个线程之间共享的静态全局数据集。

我有以下异常:

  

数据表的内部索引   损坏:5

在线程,我读的数据表和安培值;更新(用于合并)的线程进行数据表中的两个操作的价值。

解决方案

您正在做的从不同的线程数据集的操作。

该数据集不是线程安全的,你应该做一个包装类可以保护数据集从超过1操作的时间。这就是所谓的互斥:

微软MSDN

一个更好的解决方案是没有用的全局状态可言。这将解决您的问题,没有任何额外的工作,让您的code更可靠。

I have used a static Global dataset shared between a number of threads.

I got the following exception :

Data Table internal index is corrupted: '5'.

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:

link to microsoft msdn

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在穿线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆