The synchronization process in replication-based synchronization may take a long time. To avoid blocking the user interface, start a new thread to do background work.
public void Synchronize()
{
if(CheckConnectionStates())
{
Thread thread = new Thread(new ThreadStart(this. SynchronizationCore));
thread.Start();
}
// else notify user or show error message.
}
Private void SynchronizationCore()
{
XXXDB.Synchronization(new MYSyncStatusListener);
}
Private class MYSyncStatusListener: SyncStatusListener
{
// get the status and update the UI
}