Ejemplo n.º 1
0
 /// <summary>
 /// e.UserState holds state data sent from DoWork
 /// </summary>
 /// <param name="sender">BackgroundWorker</param>
 /// <param name="e"></param>
 private void BackgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
 {
     if (e.UserState != null)
     {
         ReceivedStrings.Add((string)e.UserState);
     }
     Console.WriteLine($"BW-ProgressChanged: ProgressPercentage = {e.ProgressPercentage}");
 }
Ejemplo n.º 2
0
        public void FetchData()
        {
            ReceivedStrings.Clear();

            BackgroundWorker worker = new BackgroundWorker();

            worker.DoWork += BackgroundWorker_DoWork;
            worker.WorkerReportsProgress = true;
            worker.ProgressChanged      += BackgroundWorker_ProgressChanged;
            worker.RunWorkerCompleted   += BackgroundWorker_RunWorkerCompleted;
            worker.RunWorkerAsync(new BackgrounWorkerState(dummyStringData));
        }