Merging the results of two background workers upon completion
i have two background threads
Worker = new BackgroundWorker();
Worker.DoWork += new DoWorkEventHandler(GetQuery);
Worker.RunWorkerCompleted += GetQuery_RunWorkerCompleted;
Worker.RunWorkerAsync();
Worker2012 = new BackgroundWorker();
Worker2012.DoWork += new DoWorkEventHandler(GetQuery2012);
Worker2012.RunWorkerCompleted += GetQuery2012_RunWorkerCompleted;
Worker2012.RunWorkerAsync();
both the methods in worker threads are returning data tables
now my task is i need to merge those two data tables into one
for that reason i am doing this in the RunCompletion of the first task
void GetQuerys_RunWorkerCompleted(object sender,
RunWorkerCompletedEventArgs e)
{
do{} while(Worker2012.IsBusy);
//Merge Datatables
}
but for some reason the do while loop seems to be in infinite loop. the
thread does not end. can some one tell me what i am doing wrong. or is
there a better way to wait for the second worker thread to get complete so
that i can merge data. any help would be appreciated
No comments:
Post a Comment