Question: Is there anyway of calling methodB before methodA finishes, so that methodB gets executed? Ive tried numerous ways of implementing it, and none of them worked :(

---

can someone explain? Thanks.

```
public List<ObjectA> _OurObjectA= new List<ObjectA>();

public  List<ObjectA> methodA()
{

    List<ObjectA> products = new List<ObjectA>();
    ServiceReference1.ServiceClient client = 
      new ServiceReference1.ServiceClient();
    client.getProductCompleted += 
      new EventHandler<ServiceReference1.getProductCompletedEventArgs>(methodB);

    client.getProductAsync();

    return _OurObjectA;
}

void methodB(object sender, ServiceReference1.getProductCompletedEventArgs e)
{
    ObservableCollection<ServiceReference1.ObjectA> products = e.Result;
    foreach (ServiceReference1.ObjectA obj in products)
    {
        ObjectA temp = new ObjectA(obj);
        _OurObjectA.Add(temp);
    }
}

```

Answer: 
Your client object has an [event](http://msdn.microsoft.com/en-us/library/aa645739%28v=vs.71%29.aspx) called getProductCompleted. When that event is published, methodB is executed. client.getProductAsync() is an asynchronous call, meaning it will start downloading a product in the background even though the method will return immediately. When the product is finished downloading, the client publishes the event, causing methodB to be executed.
And there's apparently an error in methodB:

```
 foreach (ServiceReference1.ObjectA obj in products)
    {
        ObjectAtemp = new ObjectA(obj);
         // no temp -- there should be a space between ObjectA and temp in the line above
         // perhaps just a typo here on SO? or in the original code?
         // EDIT: I see the code in methodB has now been corrected.
         _OurObjectA.Add(temp);
    }

```