void RunProgress(object sender, ProgressChangedEventArgs e) { if (e.UserState != null && (e.UserState is CompositionRun.State)) { CompositionRun.State state = (CompositionRun.State)e.UserState; ProgressStatus currStatus = status[state.OprIndex]; int?progress = state.Progress; if (progress != null && progress.Value > currStatus.Progress) { IBaseLinkableComponent iLC = state.StatusArgs != null ? state.StatusArgs.LinkableComponent : state.ExchangeArgs.ExchangeItem.Component; currStatus.ComponentStatus = iLC != null?iLC.Status.ToString() : ""; currStatus.LastUpdated = state.LastEventUpdate; currStatus.Progress = progress.Value; if (state.OprIndex == _nOprIndexTrigger && progressBarRun.Value != progress.Value) { progressBarRun.Value = progress.Value; UpdateTitleText(progress); _timeSpan = DateTime.Now - _startTime; string elapsed = string.Format("{0},{1},{2}.{3}", _timeSpan.Hours, _timeSpan.Minutes, _timeSpan.Seconds, _timeSpan.Milliseconds); labelMessage.Text = string.Format("Running [{0}%]\r\nElapsed {1}", progress.Value, elapsed); } dataGridViewStatus.InvalidateRow(state.OprIndex); } _logCache.Add(state); } }
void RunProgress(object sender, ProgressChangedEventArgs e) { lock (this) { if (e.UserState != null && (e.UserState is CompositionRun.State)) { CompositionRun.State state = (CompositionRun.State)e.UserState; DataGridViewCell cellComponent = _table.Cell(Table.EColumns.Component, state.OprIndex, dataGridView1); // Status DataGridViewCell cellStatus = _table.Cell(Table.EColumns.Status, state.OprIndex, dataGridView1); ILinkableComponent iLC = state.StatusArgs != null ? state.StatusArgs.LinkableComponent : state.ExchangeArgs.ExchangeItem.Component; cellStatus.Value = iLC != null?iLC.Status.ToString() : ""; dataGridView1.InvalidateCell(cellStatus); // Changes Count DataGridViewCell cellChanges = _table.Cell(Table.EColumns.Events, state.OprIndex, dataGridView1); cellChanges.Value = (int)cellChanges.Value + 1; dataGridView1.InvalidateCell(cellChanges); // Changed Time DataGridViewCell cellChanged = _table.Cell(Table.EColumns.Changed, state.OprIndex, dataGridView1); cellChanged.Value = state.LastEventUpdate; dataGridView1.InvalidateCell(cellChanged); // Changed Progress int?progress = state.Progress; if (progress != null) { DataGridViewCell cellProgress = _table.Cell(Table.EColumns.Progress, state.OprIndex, dataGridView1); cellProgress.Value = progress.Value; dataGridView1.InvalidateCell(cellProgress); if (state.OprIndex == _nOprIndexTrigger && progressBar1.Value != progress.Value) { progressBar1.Value = progress.Value; progressBar1.Invalidate(); UpdateTitleText(progress); _timeSpan = DateTime.Now - _startTime; string elapsed = string.Format("{0},{1},{2}.{3}", _timeSpan.Hours, _timeSpan.Minutes, _timeSpan.Seconds, _timeSpan.Milliseconds); labelMessage.Text = string.Format("Running [{0}%]\r\nElapsed {1}", progress.Value, elapsed); } } dataGridView1.Refresh(); _logCache.Add(state); } } }