Skip to main content

TdxServerModeCustomDataSource.OnInconsistentCache Event

Occurs after the data source has detected an inconsistency in its internal cache or failed to recover the consistency.

Declaration

property OnInconsistentCache: TdxServerModeDataSourceInconsistentCacheEvent read; write;

Remarks

Handle this event to do one of the following:

  • Notify end-users by displaying a warning message about the inconsistency;

  • Prompt them for consistency recovery with a dialog.

Sender references the data source.

The AMessage parameter contains an error message explaining the inconsistency. Use the sdxInconsistency-prefixed resource strings declared in the dxServerModeConsts unit to localize built-in messages about the inconsistency errors.

Pass True as the ARecoverCache parameter to force the data source to attempt to recover the consistency using the Refresh method call. If an attempt fails, the OnInconsistentCache event is raised again. After three consecutive attempts, the data source is closed and the OnFatalError event is raised.

If False is passed as the ARecoverCache parameter, no automatic attempts to recover the consistency are made. You need to manually attempt to accomplish this by calling the Refresh method and checking if the recovery succeeds using the IsConsistentCache function call.

The following code shows how to handle the OnInconsistentCache event to prompt end-users for consistency recovery.

procedure <Form>.<ServerModeDataSource>InconsistentCache(Sender: TdxServerModeCustomDataSource; const AMessage: string; var ARecoverCache: Boolean);
begin
  ARecoverCache := MessageDlg('The cache state is inconsistent. Do you want to recover it?', mtError, [mbYes, mbNo], 0) = mrYes;
  if not ARecoverCache then
    Sender.Close;
end;
See Also