Contents Index Monitoring and canceling synchronization Configuring development tools for UltraLite development pdf/preface.pdf

UltraLite User's Guide
  Developing UltraLite Applications
    Adding synchronization to your application

Writing a synchronization callback function


The callback function that you use to monitor synchronization takes a ul_synch_status structure as parameter. The ul_synch_status structure has the following members:

Example 

The following code illustrates how a very simple observer function could be implemented:

extern void __stdcall ObserverFunc(
    p_ul_synch_status status )
{
    printf( "UL_SYNCH_STATE is %d: ",
            status->state );
    switch( status->state ) {
        case UL_SYNCH_STATE_STARTING:
        printf( "Starting\n");
        break;
    case UL_SYNCH_STATE_CONNECTING:
        printf( "Connecting\n"  );
        break;
    case UL_SYNCH_STATE_SENDING_HEADER:
        printf( "Sending Header\n" );
        break;
    case UL_SYNCH_STATE_SENDING_TABLE:
        printf( "Sending Table %d of %d\n",
                status->tableIndex + 1,
                status->tableCount );
        break;
...

This function produces the following output when synchronizing two tables:

UL_SYNCH_STATE is 0: Starting
UL_SYNCH_STATE is 1: Connecting
UL_SYNCH_STATE is 2: Sending Header
UL_SYNCH_STATE is 3: Sending Table 1 of 2
UL_SYNCH_STATE is 3: Sending Table 2 of 2
UL_SYNCH_STATE is 4: Receiving Upload Ack
UL_SYNCH_STATE is 5: Receiving Table 1 of 2
UL_SYNCH_STATE is 5: Receiving Table 2 of 2
UL_SYNCH_STATE is 6: Sending Download Ack
UL_SYNCH_STATE is 7: Disconnecting
UL_SYNCH_STATE is 8: Done
CustDB example 

An example of an observer function is included in the CustDB sample application. The implementation in CustDB provides a dialog that displays synchronization progress and allows the user to cancel synchronization. The user-interface component makes the observer function platform specific.

The CustDB sample code is in the Samples\UltraLite\CustDB subdirectory of your SQL Anywhere directory. The observer function is contained in the platform-specific subdirectories of the CustDB directory.


Contents Index Monitoring and canceling synchronization Configuring development tools for UltraLite development pdf/preface.pdf