Skip to main content

TcxCustomSchedulerStorage.BeginUpdate Method

Acquires a lock on the data controller to prevent View update callbacks being made to the registered IcxSchedulerStorageListener listener by the data controller, until a block of data update statements has finished executing.

Declaration

procedure BeginUpdate; virtual;

Remarks

This method is combined with the EndUpdate method (that releases the lock) to contain a block of update statements. Since the execution of the block of statements can exit with either a normal or exception state, these statements and the EndUpdate method should be contained within try… finally… blocks following the BeginUpdate method to ensure that the lock will be released in all cases.

For clarity a code sample is given below:

//...
var
  I: Integer;
  AEvent: TcxSchedulerEvent;
begin
  cxSchedulerStorage.BeginUpdate;
  try
    for I := 0 to 1 do
    begin
      AEvent := cxScheduler.Storage.CreateEvent;
      AEvent.Start := EncodeDateTime(2004, 7, 7, 10, 0, 0, 0);
      AEvent.Duration := Random(100) / 500;
      AEvent.Message := 'Created on start up';
      AEvent.Caption := 'Event # ' + IntToStr(I);
    end;
  finally
    cxSchedulerStorage.EndUpdate;
  end;
end;
See Also