Beispiel #1
0
        private void ItemWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker bw  = sender as BackgroundWorker;
            ISchema          sch = workingList.Schema;

            bw.ReportProgress(0, "Setting up...");
            sch.PrepareRefresh(taskType, workingList, workingList.SchemaParams);
            bw.ReportProgress(0, "Adding item #1 of " + sch.GetTotalProgress());
            int xyz = 0;             //TODO remove

            while (sch.GetProgress() < sch.GetTotalProgress() && (++xyz) < 10)
            {
                if (bw.CancellationPending)
                {
                    e.Cancel = true;
                    break;
                }
                switch (taskType)
                {
                case SyncTask.ALL: sch.RefreshAll(workingList); break;

                case SyncTask.NEW: sch.FindNew(workingList); break;

                case SyncTask.UPDATE: sch.RefreshCurrent(workingList); break;

                case SyncTask.ONE: sch.RefreshOne(workingList, e.Argument as SyncItem); break;

                default: throw new NotImplementedException();
                }
                Console.WriteLine("Adding item #" + sch.GetProgress() + " of " + sch.GetTotalProgress());
                bw.ReportProgress(sch.GetProgress() * 100 / sch.GetTotalProgress(),
                                  "Adding item #" + sch.GetProgress() + " of " + sch.GetTotalProgress());
            }
            sch.FinishRefresh();
        }