locked
Progressbar again RRS feed

  • Question

  • Still trying to make a progressbar for my sync.

    I added a eventhandler to the

    SessionProgress event in my SyncAgent class. I finely found the SyncStage.DownloadingChanges.

    But I onely get this two times for ones sync batch. When It starts syncing the SessionProgressEventArgs.PercentCompleted has a value of 55 and when it is done the SessionProgressEventArgs.PercentCompleted has a value of 91. Is there any way to get this event to fire after every row it downloads like it does when SyncStage.ApplyingUpdates? A progressbar that jumps to 55% and then stands still for the entire downloading process an finaly jumps to 91% is not what I want.

     

    /Christer

    • Moved by Max Wang_1983 Friday, April 22, 2011 4:49 PM forum consolidation (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Tuesday, September 23, 2008 9:07 PM

All replies

  • Hey,

     

    I implemented progress bar like this:

     

    Code Snippet

    private void syncEngine_SyncProgress(object sender, SyncProgressEventArgs e)

    {

    int progress = 0;

    if (e.TableProgress.TotalChanges > 0)

    {

    progress = Convert.ToInt32((Convert.ToDecimal(e.TableProgress.ChangesApplied) /

    Convert.ToDecimal(e.TableProgress.TotalChanges)) * 100);

    }

    bwSync.ReportProgress(progress, e);

    }

     

     

     

    Where bwSync is my background worker variable. I used this code to show progress of each table not the entire sync process.
    Wednesday, September 24, 2008 6:02 AM
  • I have something similar. I have a SyncProgress eventhandler both in my SyncAgent class and in my SyncProvider class. But none of them will be triggered when the sync framework is downloading changes over the wire thorugh WCF.

    I have about 500 Mb of data that will bee downloaded the first time I syncronize and that is taking a lot of time to do that.

    Is it at all possible to get the SyncProgress event to fire while downloading changes?

    Wednesday, September 24, 2008 8:30 AM
  • I have found code in a sample project like this. Works fine in my project.
          
    clientSyncProvider.SyncProgress += new EventHandler<SyncProgressEventArgs>(Report);



    private void Report(object sender, SyncProgressEventArgs args)
            {
                string message = "Progress: ";

                switch (args.SyncStage)
                {
                    case SyncStage.ApplyingInserts:
                        message += "Applying insert for table: " + args.TableMetadata.TableName;
                        message += "[" + args.TableProgress.Inserts.ToString() + "|" + args.TableProgress.Updates.ToString() + "|" + args.TableProgress.Deletes.ToString() + "]";
                        message += "(Applied:" + args.TableProgress.ChangesApplied.ToString() + "/Pending:" + args.TableProgress.ChangesPending.ToString() +
                           "/Failed:" + args.TableProgress.ChangesFailed.ToString() + "/Total:" + args.TableProgress.TotalChanges.ToString() + ")";
                        break;

                    case SyncStage.ApplyingUpdates:
                        message += "Applying update for table: " + args.TableMetadata.TableName;
                        message += "[" + args.TableProgress.Inserts.ToString() + "|" + args.TableProgress.Updates.ToString() + "|" + args.TableProgress.Deletes.ToString() + "]";
                        message += "(Applied:" + args.TableProgress.ChangesApplied.ToString() + "/Pending:" + args.TableProgress.ChangesPending.ToString() +
                            "/Failed:" + args.TableProgress.ChangesFailed.ToString() + "/Total:" + args.TableProgress.TotalChanges.ToString() + ")";
                        break;

                    case SyncStage.ApplyingDeletes:
                        message += "Applying delete for table: " + args.TableMetadata.TableName;
                        message += "[" + args.TableProgress.Inserts.ToString() + "|" + args.TableProgress.Updates.ToString() + "|" + args.TableProgress.Deletes.ToString() + "]";
                        message += "(Applied:" + args.TableProgress.ChangesApplied.ToString() + "/Pending:" + args.TableProgress.ChangesPending.ToString() +
                            "/Failed:" + args.TableProgress.ChangesFailed.ToString() + "/Total:" + args.TableProgress.TotalChanges.ToString() + ")";
                        break;

                    case SyncStage.GettingInserts:
                        message += "Enumerating inserts for table: " + args.TableMetadata.TableName;
                        message += "[" + args.TableProgress.Inserts.ToString() + "|" + args.TableProgress.Updates.ToString() + "|" + args.TableProgress.Deletes.ToString() + "]";
                        break;

                    case SyncStage.GettingUpdates:
                        message += "Enumerating updates for table: " + args.TableMetadata.TableName;
                        message += "[" + args.TableProgress.Inserts.ToString() + "|" + args.TableProgress.Updates.ToString() + "|" + args.TableProgress.Deletes.ToString() + "]";
                        break;

                    case SyncStage.GettingDeletes:
                        message += "Enumerating deletes for table: " + args.TableMetadata.TableName;
                        message += "[" + args.TableProgress.Inserts.ToString() + "|" + args.TableProgress.Updates.ToString() + "|" + args.TableProgress.Deletes.ToString() + "]";
                        break;
                }
                statusTb.Text = message;
            }

    Wednesday, September 24, 2008 10:02 AM
  • Seems like you have not added SyncProgress event handler for your clientSyncProvider. I'm using SqlExpressProvider and added event handler like this:

    clientSyncProvider.SyncProgress += new EventHandler<SyncProgressEventArgs>(clientSyncProvider_SyncProgress);
    Wednesday, September 24, 2008 10:19 AM
  •  

    I have added the SyncProgress eventhandler in both my SyncAgent Class and my SyncProvider class on my Client.

    I am still not getting any event before the one where the SyncProgressEventArgs.SyncStage == SyncStage.ApplyingInserts. What I am looking for is the time After the SyncStage.GettingInserts and before SyncStage.ApplyingInserts. Because my project have alot of data. About 500 Mb to transfer the first time a user opens the application. I read the answer in this post. http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3410415&SiteID=1 about getting more information about UploadingChanges and DownloadingChanges with SessionProgressEvent in the SyncAgent class. But that event only fires two times for my 500 Mb download. The first time it fires is before enything is downloaded and the second time is after everyting is downloaded. Is it possible to get the event to fire more than that? I have 500Mb of data to download and that takes alot of time for user with poor internet connections (several hours). If the event only fires before and arfter the download the progressbar will not move the entire time in this case several hours. To me that is not a good progressbar! I use WCF because I do not want to expose my SQL server over the Internet. On the Client I use SQL CE 3.5.  Is that a problem for the SyncProgressEvent?

    Is there anyone that can help me on this one?

     

    /Christer

     

    Wednesday, September 24, 2008 12:37 PM