下面的row["FileProgress"] = e.ProgressPercentage;
代码给出了错误VersionNotFoundException
。请帮助,因为它对应用程序造成严重破坏,我也面临异常:DataTable 内部索引已损坏:随机多次出现“5”。
BackgroundWorker ProgressChanged 代码
private void bwTransferQueue_ProgressChanged(object sender, System.ComponentModel.ProgressChangedEventArgs e)
{
DataRow row = e.UserState as DataRow;
if (row != null)
{
row["FileProgress"] = e.ProgressPercentage; <--- VersionNotFoundException
}
}
BackgroundWorker DoWork 代码
private void bwTransferQueue_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
{
DataRow row = e.Argument as DataRow;
try
{
if (row != null)
{
// some code
bwTransferQueue.ReportProgress(0, row);
}
}
catch (WebException webex)
{
row["Status"] = QueueType.Failed;
row["StatusDescription"] = webex.Status;
e.Result = row;
}
catch (Exception ex)
{
row["Status"] = QueueType.Failed;
row["StatusDescription"] = ex.Message;
e.Result = row;
}
}
启动后台工作者的代码
private void startWorker()
{
try
{
if (StartQueue && dtTransferQueue.Rows.Count > 0 && !bwTransferQueue.IsBusy)
{
DataRow[] rows = dtTransferQueue.Select(string.Format("Status = '{0}'", QueueType.Pending.ToString()));
if (rows.Length > 0)
{
tsmiProgressBar.Visible = true;
bwTransferQueue.RunWorkerAsync(rows[0]);
}
}
}
catch (Exception ex)
{
CommonLogic.HandleError(ex);
}
}