title: Silverlight Webservice Problem
body: <p>I have a webservice that calls a method and returns a generic list.  The webservice completed method looks like this (note: names and e.Result are both of the same type of List):</p>
  
  <pre><code>   void SetNames()
     {    
          ServiceReference1.ServiceClient webservice = new ServiceReference1.ServiceClient();
  
          webservice.GetNameCompleted += new EventHandler&lt;GetNameCompletedEventArgs&gt;(webservice_GetNameCompleted);
          webservice.GetNameAsync();
      }
      private void webservice_GetNameCompleted(object sender, ServiceReference1.GetNameCompletedEventArgs e)
      {
         names = e.Result;     
      }
  </code></pre>
  
  <p>The problem I'm having is that I can only retrieve the items in the names list in the webservice method.  Whenever I try to access the items in the names list anywhere outside of that method it is empty.  For example (this displays nothing in the textbox),</p>
  
  <pre><code>List&lt;string&gt; names = new List&lt;string&gt;();
  
  public MainPage()
  {
      InitializeComponent();
      SetNames();
  
      foreach (string name in names)
          textBox1.Text += name;
   }
  </code></pre>
  
  <p>But this will display the correct thing:</p>
  
  <pre><code>private void webservice_GetNameCompleted(object sender, ServiceReference1.GetNameCompletedEventArgs e)
      {
         names = e.Result;
  
         foreach (string name in names)
            textBox1.Text += name;     
      }
  </code></pre>
  
  <p>I'm new to Silverlight and webservies, and I'm probably over looking something.  I've been working on this for a while and I'm at the point where I feel I need to ask for help.  Any help would be greatly appreciated!</p>