我有一个清单。我把所有查询输出放在哪里。现在使用线程做一些处理。所以当工作完成后,需要更新列表项的值。请在下面查看我的代码:
公开名单:
public static List<string[]> OutboxList = new List<string[]>();
从数据库中获取数据并操作列表:
OutboxQueryCommand.CommandText = "SELECT top 5 id, status from TableA";
SqlDataReader OutboxQueryReader = OutboxQueryCommand.ExecuteReader();
while (OutboxQueryReader.Read())
{
string[] OutBoxFields = new string[7];
OutBoxFields[0] = OutboxQueryReader["id"].ToString();
OutBoxFields[1] = OutboxQueryReader["status"].ToString();
OutboxList.Add(OutBoxFields);
}
foreach (string[] OutBoxFields in OutboxList)
{
id = OutBoxFields[0];
status = OutBoxFields[1];
Thread OutboxThread = new Thread(() => OutboxThreadProcessor(id,status));
OutboxThread.Start();
}
通过线程调用方法:
static void OutboxThreadProcessor(string id,string status)
{
//predefine value of status is "QUE". Process some work here for that perticular item list.if data process success full then need to update
// the status of the list item
// need to update the perticular value of that list item here.
How i do it???????
//Say for Example 1-> Success
// 2-> Failed
// 3-> Success
}