BackgroundWorker is the easiest. The following code shows how this is done:
public MainWindow()
{
InitializeComponent();
var bw = new BackgroundWorker();
bw.DoWork += new DoWorkEventHandler(bw_DoWork);
bw.WorkerSupportsCancellation = true;
bw.WorkerReportsProgress = true;
bw.ProgressChanged += new ProgressChangedEventHandler(bw_ProgressChanged);
bw.RunWorkerAsync();
}
void bw_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
var newText = e.UserState;
}
void bw_DoWork(object sender, DoWorkEventArgs e)
{
var bw = (BackgroundWorker) sender;
while (!bw.CancellationPending)
{
var newText = "Put new information here";
bw.ReportProgress(1, newText);
}
}
Your problem will be is providing progress. The only good idea I can tell you is to only a few of the records at a time. So get the count of records, and then do an appropriate Skip and Take, reporting progress change in the end. The other option is to guess how long it will take, and have another BackgoundWorker that will report progress.