I have a program which loops through an apps list.
Apps
--------
App1
App2
App3
Now, for each of them, I do a http request to get a list of builds for each app as an Xml.
So a request like,
http://example.com/getapplist.do?appid=App1
gives me a response like,
<appid name="App1">
<buildid BldName="Bld3" Status="Not Ready"></buildid>
<buildid BldName="Bld2" Status="Ready"></buildid>
<buildid BldName="Bld1" Status="Ready"></buildid>
</appid>
Now I get the Highest build number with Status "Ready" and then do another web api call like,
http://example.com/getapplist.do?appid=App1&bldid=Bld2
This gives me a response like,
<buildinfo appid="App1" buildid="Bld2" value="someinfo"></build>
I feed these into internal data tables. But now, this program takes a painfully long time to complete (3 hours), since I have close to 2000 appids and there are 2 Web requests for each id. I tried sorting this issue using a BackgroundWorker as specified here. I thought of collating all info from http responses into a single XML and then using that XML for further processing. This throws the error,
file being used by another process
So my code looks like,
if (!backgroundWorker1.IsBusy)
{
for(int i = 0; i < appList.Count; i++)
{
BackgroundWorker bgw = new BackgroundWorker();
bgw.WorkerReportsProgress = true;
bgw.WorkerSupportsCancellation = true;
bgw.DoWork += new DoWorkEventHandler(bgw_DoWork);
bgw.ProgressChanged += new ProgressChangedEventHandler(bgw_ProgressChanged);
bgw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bgw_RunWorkerCompleted);
//Start The Worker
bgw.RunWorkerAsync();
}
}
And the DoWork
function picks the tag values and puts it into an XML.
What is the best way I can get the app- buildinfo details into a common file from all the http responses from all the background workers?