Link to home
Start Free TrialLog in
Avatar of puckkk
puckkk

asked on

Background Worker and returning values

Hello all. Morning question...
I have the main thread running my main form. I use a backgroundworker when user click button to use a webservice that controls european VAT. my code is:

//...
MBForm.Showdialog() // form whre is shown the progress of the webservice running on the Background Thread
Backgroundworker.RunWorkerASynch();

//... BackGroundWorker_Dowork()
Webservice.run()

All that I need is: How can I have retuning values when the background worker has finished the work? I mean the Webservice is controlling the european VAT returning bool valid and string name and string address. How can I have this three returning values for using it on the main Thread? Do I have to assingn these values on a global variable of is there a better way? Thx in advance
ASKER CERTIFIED SOLUTION
Avatar of AlexFM
AlexFM

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of puckkk
puckkk

ASKER

Nice. Thx a lot agian man.
Avatar of puckkk

ASKER

Sorry Alex, just one more thing...
   OperationResult r = new Result();   // OperationResult  is your class which contains results of background operation
 r.Name = ...;
    r.Address = ...;     // fill result properties

What is the best way to create OperationResult class?

public class Operation Result
{
        string name;
        string address
        OperationResult(string _name, string address)
        {
             name=_name;
             address = _address;

        }
}

Or is there a better way to create an object assigning to properties to it? Thx again
Any way that is convenient for you: class with constructor and read-only properties, class with read/write properties. Anything that allows to keep information and read it. As example of such clas, which is designed only for keeping parameters, see ProcessStartInfo class.
Avatar of puckkk

ASKER

Thx a lot.