I am running a BackgroundWorker to make a call to a Web Service to obtain a list of Customers, and a list of Vat Rates. This is fine and works, but I am simply stuck passing this data through to RunWorkerCompleted so the form can be updated (these two sets of data populate two combo boxes)

private void bwWebServiceCalls_DoWork(object sender, DoWorkEventArgs e)
            //Get customers
            Invoice.Customer[] customers = new Invoice.Customer[0];
            customers = this.wsInvoice.getCustomers("user", "pw");

            //Get Vat Rates
            Invoice.Vat[] vats = new Invoice.Vat[0];
            vats = this.wsInvoice.getVatRates("user", "pw");

            e.Result = ;

This is incomplete code! If anyone can point me in the right direction on how to send the two objects (customers and vats) through e.result, and how to split these out in RunWorkerCompleted it would be very much appreciated.

I have thought about running two BackgroundWorkers (one for each) as I have done this singulaly, buy am worried that it would result in two WebService calls, and is not as neat as it could be.

If I am completely on the wrong track, again any pointers would be great.

I have been creating a class that has those parameters and then passing the class to the RunWorkerCompleted.

internal class MyClass
  public Customer[] oParam1;
  public Vat[] oParam2;

  public MyClass(Customer[] o1, Vat[] o2)
    //Set variables here
e.Result = new MyClass(this.wsInvoice.getCustomers("user", "pw"), his.wsInvoice.getVatRates("user", "pw"));  //Or these can be set to variables and then passed as parameters

BTW adatapost, e.Result allows get & set operations.

~ Orthimnas ~

This article has been dead for over six months. Start a new discussion instead.