title: Overcoming asynchronous nature of WebClient.OpenReadAsync when building Silverlight video player
body: <p>Dear fellow programmers at Stackowverflow.com or anyone knowledgeable,</p>
  
  <p>I am presently building my first real life application using RadControls for Silverlight from Telerik. So far I pretty much like it and controls whether in Silverlight or from third parties are really powerful. This particular application is essentially a video player built around RadMediaPlayer. Now you do need to understand specifics of RadMediaPlayer in order to help me. As it stands, my issue is related straight to core Silverlight programming, my language of choice being C#.
      I have two external XML files. First one contains configuration information like width and height of video player. Here is how it looks like in present form.</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
   &lt;video_player_config&gt;
           &lt;video_contentdescription_file&gt;http://localhost:83/JSVP_Video_player/Playlist.media.xml&lt;/video_contentdescription_file&gt;
           &lt;videoplayer_width&gt;300&lt;/videoplayer_width&gt;
           &lt;videoplayer_height&gt;300&lt;/videoplayer_height&gt;
       &lt;/video_player_config&gt;
  </code></pre>
  
  <p>The second one contains data for media items in the following structure:</p>
  
  <pre><code>&lt;mediaItems&gt;
  
      &lt;mediaItem&gt;
        &lt;title&gt;&lt;/title&gt;
        &lt;description&gt; &lt;/description&gt;
        &lt;mediaUrl&gt; &lt;/mediaUrl&gt;
        &lt;imageUrl&gt; &lt;/imageUrl&gt;
  </code></pre>
  
  <p>etc.</p>
  
  <p>Now I have written a static class named “SichulaVideoPlayerConfig” that opens XML confi-guration file using WebClient and then parses it using LINQ to XML. This works fine on its own. The trouble is that when I call SichulaVideoPlayerConfig.LoadConfigFile during Appli-cation_Startup in app.xaml.cs, the data from XML configuration file are not yet there and the player UI initializes as empty.
  It seems to me that the problem is related to the asynchronous nature of WebClient.OpenReadAsync method. I understand that it runs on different thread than UI. Because of that my UI initializes and yet data from XML file are still not available.
  I kindly ask for help in how to overcome this unwanted situation. A working code example would be most welcome and I have already read much theory but to no avail.
      Kindly please, please, help me.</p>
  
  <p>Jan Sichula
  (Slovak Republic)</p>
  
  <p><a href="http://sichula.temelios.sk/" rel="nofollow noreferrer">http://sichula.temelios.sk/</a> (English website for friends – family photos, videos and newsletter archive)</p>