Asynchronous Operation Replay

Upload operation replay records asynchronously.

When an application calls SubmitPending on an MBO on which a create, update, or delete operation is performed, an operation replay record is created on the device local database.

When Synchronize is called, the operation replay records are uploaded to the server. The method returns without waiting for the backend to replay those records. The Synchronize method downloads all the latest data changes and the results of the previously uploaded operation replay records that the backend has finished replaying in the background. If you choose to disable asynchronous operation replay, each Synchronize call will wait for the backend to finish replaying all the current uploaded operation replay records.

When SAP Mobile Platform does an update operation replay, if the primary key or foreign key of the MBO is generated by the EIS and the MBO's content coming from the device has no primary key or foreign key, the SAP Mobile Server loads the primary key or foreign key from the CDB to merge the incoming values with the CDB content so that a full row (graph) can be communicated to the EIS.

oneMBO mbo = new oneMBO();
mbo.SetXX(xx);
....
mbo.Create();
mbo.SubmitPending();
mbo.SetXX(yy);
....
mbo.Update();
mbo.SubmitPending();
DBClass.Synchronize()
This feature is enabled by default. You can enable or disable the feature by setting the asyncReplay property in the synchronization profile. The following code shows how to disable asynchronous replay:
SMP101DB.GetSynchronizationProfile().AsyncReplay = false;

When the application is connected (by Application.StartConnection() or Application.RegisterApplication), it may receive background notifications and trigger a synchronize or other database operation. If you try to delete the database, you may receive database exceptions.

Before deleting the database, stop the application connection (Application.StopConnection()).

You can specify an upload-only synchronization where the client sends its changes to the server, but does not download other changes from the server. This type of synchronization conserves device resources when receiving changes from the server.
public static void BeginSynchronize(Sybase.Collections.GenericList<Sybase.Persistence.ISynchronizationGroup> sgs,object context, bool uploadOnly)
When asynchronous replay is enabled and the replay is finished, the OnSynchronize callback method is invoked with a SynchronizationStatus value of SynchronizationStatus.ASYNC_REPLAY_COMPLETED. Use this callback method to invoke a synchronize call to pull in the results, as shown in the following callback handler.
public virtual SynchronizationAction OnSynchronize( 
  Sybase.Collections.GenericList<ISynchronizationGroup> groups,
  SynchronizationContext context)
{
  switch(context.Status)
  {
    case SynchronizationStatus.ASYNC_REPLAY_UPLOADED:
      LogMessage("AsyncReplay uploaded");
      break;
    case SynchronizationStatus.ASYNC_REPLAY_COMPLETED:
      // operation replay finished
      if (busy)
      {
        // if busy, don't do synchronize now
        return SynchronizationAction.CANCEL;
      }
      break;
    default:
      break;
  }
            return SynchronizationAction.CONTINUE;
}