The calculation for SessionProgressEventArgs.PercentCompleted is buggy:

The values for PercentCompleted are calculated in SyncAgent.DataSynchronize() like this (code from Reflector):

num2 = (15 + ((40 / uploadMetadata.Count) * i))

(in download stage, 15 is replaced with 55)

(see Microsoft.Synchronization.SyncAgent.DataSynchronize() in assembly Microsoft.Synchronization.Data)

The problem is, that

40 / uploadMetadata.Count

seems to return a truncated Integer value. So for uploadMetadata.Count > 40, this value is always zero.

This results in the calculated progress value always being 15 (upload) or 55 (download).

I tested this with Sync Framework versions 1.0 and 3.1.

I verified it for the download stage, since there are only 28 tables being uploaded but 58 tables being downloaded in my project

(PercentCompleted gets stuck at 55% for the whole download stage, then jumps to 100%)

Since I can't really fix this problem myself, does anyone have an idea how to get the data needed to calculate progress?

The SessionProgressEventArgs provides BatchNumber/BatchCount, but they are reset after each table (BatchNumber is 0 before changes are applied and 1 afterwards; BatchCount is always = 0)