I'm trying to use BackgroundWorker
to load-test a web service,
Code is:
private void button1_Click(object sender, EventArgs e)
{
CheckWS("11111");
CheckWS("22222");
CheckWS("3344111");
// .. and some more of those, approx 1000
}
public void CheckWS(string sUser)
{
BackgroundWorker bgWork = new BackgroundWorker();
bgWork.DoWork += new DoWorkEventHandler(bgWork_DoWork);
sObject sData = new sObject();
sData.iNum = iCount++;
sData.sId = sUser;
bgWork.RunWorkerAsync(sData);
}
public void bgWork_DoWork(object sender, DoWorkEventArgs e)
{
// Update a textbox that this worker started
...
// Run a web service
...
// Update the textbox as worker ended
}
But according to the time taken for the job the get done, and according to the output of the workers (worker begin&end in the textbox), it takes way too long for each worker to start -
I would expect everything to run simultaneously, but instead, it executes only 2-3 background workers at a time...
Any ideas on this issue?