Create a Custom Callback Handler

If an application requires a callback (for example, to allow the client framework to provide notification of synchronization results) create a custom callback handler.

public class Test
{
  public static void Main(String[] args)
  {
  ...
    SUP101DB.RegisterCallbackHandler(new MyCallbackHandler());
    ...
    GenericList<ISynchronizationGroup> sgs = new GenericList<ISynchronizationGroup>();
    sgs.Add(SUP101DB.GetSynchronizationGroup("sg1"));
    sgs.Add(SUP101DB.GetSynchronizationGroup("sg2"));
    SUP101DB.BeginSynchronize(sgs, "my test synchronization context");
  }
}

public class MyCallbackHandler : Sybase.Persistence.DefaultCallbackHandler
{
  public override Sybase.Persistence.SynchronizationAction OnSynchronize(Sybase.Collections.GenericList<Sybase.Persistence.ISynchronizationGroup> groups, Sybase.Persistence.SynchronizationContext context)
  {

    if (context == null
    {
      return Sybase.Persistence.SynchronizationAction.CANCEL;
    }

    if ("my test synchronization context".Equals(context.UserContext))
    {
      return base.OnSynchronize(groups, context);
    }

    switch (context.Status)
    {
      case SynchronizationStatus.STARTING:
        if (WaitForMoreChanges())
        {
          return SynchronizationAction.CANCEL;
        }
        else
        {
          return SynchronizationAction.CONTINUE;
        }
      default:
        return SynchronizationAction.CONTINUE;
    }
    return SynchronizationAction.CONTINUE;
  }
}