Hey, thanks for the detailed post. I’ll try to address a few points here:
- To get progress notifications you can set the
OnProgressproperty on your sync configuration. It’s a callback that gets invoked as data is being downloaded similarly to thesession.GetProgressObservablecode you have:var config = new SyncConfiguration(user, "my-partition") { OnProgress = progress => { // Convert the reported bytes in a 0-100% range. var progressPercentage = 100.0 * progress.TransferredBytes / progress.TransferableBytes; this.ProgressIndicator.Progress = progressPercentage; } }; -
RefreshAsyncdoes not do any synchronization with the server, but rather updates your local database with changes that may have happened on background threads. This happens automatically when you’re on the main thread and the thread is idle, but you can useRefreshAsyncto force update it. An example of this would be, if you download some data via a REST call, insert it on a background thread to avoid blocking the main thread with a large write, then want to lookup the newly inserted objects on the main thread. Callingawait RefreshAsyncwill ensure that the newly inserted objects are available without introducing race conditions. - If you want to ensure the Realm is synchronized, you can use
Session.WaitForDownloadAsync. It will resolve once the download has completed. It can be used independently or in combination withGetProgressObservable. Generally speaking,WaitForDownloadAsyncis more efficient than tracking progress, so if you just want to ensure the Realm has been synchronized without displaying progress bars, this is the recommended approach. - The
IObservablereturned byGetProgressObservablewithProgressMode.ForCurrentlyOutstandingWorkwill complete once the upload/download has completed. So rather than checking fortransferred >= transferrable, you can provide aOnCompletecallback when subscribing.
I hope that clarifies the questions you’ve had. Finally, I’d like to point you to the warnings on this docs page as those are in effect both when using GetProgressObservable and when using SyncConfiguration.OnProgress.