本文介绍了多维数据表和多线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试为多线程锁定一个多维DataTable,目前我正在使用以下代码,但它似乎不起作用,任何帮助将不胜感激。
我可以通过以下方式锁定DataTable,如果没有,请您举个例子,
提前感谢。
Michael
我尝试过:
lock(MyDataSet [n,x] .MyDataTable)
{
MyDataSet [n,x] .MyDataTable [record] .Name =John;
}
I am trying to lock a multi-dimensional DataTable for multi-Threading, currently I am using the following code but it does not seem to work, any help would be greatly appreciated.
Can I lock the DataTable the following way, if not can you please give an example,
thanks in advance.
Michael
What I have tried:
lock (MyDataSet[n, x].MyDataTable)
{
MyDataSet[n, x].MyDataTable[record].Name = "John";
}
推荐答案
lock (MyDataSet[n, x].MyDataTable.Rows.SyncRoot)
{
MyDataSet[n, x].MyDataTable.Rows[record].Name = "John";
}
这篇关于多维数据表和多线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!