private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { HashSet <int> added = new HashSet <int>(); double count = 0; ActiveSurveyList surveyList = new ActiveSurveyList(); surveyList.BackgroundListLoad(); if (surveyList != null) { surveyList.Sort(delegate(HraObject a, HraObject b) { return(((ActiveSurvey)a).surveyID.CompareTo(((ActiveSurvey)b).surveyID)); }); foreach (ActiveSurvey o in surveyList) { count++; if (added.Contains(o.surveyID) == false) { added.Add(o.surveyID); double percent = 100 * count / (double)(surveyList.Count); ActiveSurveyRow asr = new ActiveSurveyRow(o); backgroundWorker1.ReportProgress((int)percent, asr); System.Threading.Thread.Sleep(25); } } } e.Result = count; }
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { HashSet<int> added = new HashSet<int>(); double count = 0; ActiveSurveyList surveyList = new ActiveSurveyList(); surveyList.BackgroundListLoad(); if (surveyList != null) { surveyList.Sort((a, b) => a.surveyID.CompareTo(b.surveyID)); foreach (ActiveSurvey o in surveyList) { count++; if (added.Contains(o.surveyID) == false) { added.Add(o.surveyID); double percent = 100 * count / (double)(surveyList.Count); ActiveSurveyRow asr = new ActiveSurveyRow(o); backgroundWorker1.ReportProgress((int)percent, asr); System.Threading.Thread.Sleep(25); } } } e.Result = count; }
private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e) { progressBar1.Value = e.ProgressPercentage; ActiveSurveyRow asr = (ActiveSurveyRow)e.UserState; flowLayoutPanel1.Controls.Add(asr); loadCountLabel.Text = flowLayoutPanel1.Controls.Count.ToString(); }