コード例 #1
0
        /// <summary>
        /// Called on the target table thread - copies adds/updates/deletes
        /// </summary>
        /// <param name="rowUpdatesAdd"></param>
        /// <param name="colUpdaters"></param>
        /// <param name="rowUpdatesDelete"></param>
        private void CopyChanges(List <TableUpdate> rowUpdatesAdd, List <ITableColumnUpdater> colUpdaters, List <TableUpdate> rowUpdatesDelete)
        {
            try
            {
                // Copy the adds
                if (rowUpdatesAdd != null)
                {
                    for (var i = 0; i < rowUpdatesAdd.Count; i++)
                    {
                        _targetTable.AddRow();
                    }
                }

                // Copy the updates
                foreach (var updater in colUpdaters)
                {
                    updater.SetValues(_targetTable);
                }

                // Copy the deletes
                if (rowUpdatesDelete != null)
                {
                    for (var i = 0; i < rowUpdatesDelete.Count; i++)
                    {
                        _targetTable.DeleteRow(rowUpdatesDelete[i].RowIndex);
                    }
                }
            }
            finally
            {
                StartTimer();
            }
        }
コード例 #2
0
 public void OnNext(TableUpdate update)
 {
     _threadMarshaller.Dispatch(
         () =>
     {
         if (update.Action == TableUpdateAction.Add)
         {
             var newRowIndex = _targetTable.AddRow();
             Debug.Assert(update.RowIndex == newRowIndex);
         }
         else if (update.Action == TableUpdateAction.Delete)
         {
             _targetTable.DeleteRow(update.RowIndex);
         }
         else if (update.Action == TableUpdateAction.Update)
         {
             // BUG: When this line is called the original update.Column may not contain the same state as when the outside method is called.
             _targetTable.SetValue(update.Column.ColumnId, update.RowIndex, update.Column, update.RowIndex);
         }
     });
 }
コード例 #3
0
        private void SynchroniseChanges(object state)
        {
            // Make copies to control exactly when we lock
            List <TableUpdate> updates;

            lock (_shared)
            {
                if (_updates.Count == 0)
                {
                    return;
                }

                updates = _updates.DequeueAllToList();
            }

            _threadMarshaller.Dispatch(
                () =>
            {
                foreach (var update in updates.Where(TableUpdate.IsRowUpdate))
                {
                    if (update.Action == TableUpdateAction.Add)
                    {
                        _targetTable.AddRow();
                    }
                    else if (update.Action == TableUpdateAction.Delete)
                    {
                        _targetTable.DeleteRow(update.RowIndex);
                    }
                }

                // BUG: When this line is called the original update.Column may not contain the same state as when the outside method is called.
                foreach (var update in updates.Where(TableUpdate.IsColumnUpdate))
                {
                    _targetTable.SetValue(update.Column.ColumnId, update.RowIndex, update.Column, update.RowIndex);
                }
            });
        }