title: Close the main application from a different thread
body: <p>I am developing an application which is written by c# + HTML + Java Script in the following structure: 
  the base window is a WPF MainWindow class that opens a thread which creates a web page. This thread handles all the UI events. </p>
  
  <p>The WebBrowser XAML code is:</p>
  
  <pre><code>    &lt;WebBrowser x:Name="CordovaBrowser" 
          Opacity="0"
          HorizontalAlignment="Stretch"  
          VerticalAlignment="Stretch" 
          Loaded="CordovaBrowser_Loaded" 
          Unloaded="CordovaBrowser_Unloaded"   
          LoadCompleted="CordovaBrowser_LoadCompleted" 
       /&gt;
  </code></pre>
  
  <p>The problem is that I want to close the application from the HTML thread.
  I cannot use App.Current.ShutDown() because I'm not in the main UI thread (I've tried to do so but got an exception).</p>
  
  <p>(BTW: For who knows PhoneGap: my application structure is very similar to how the Win8 PhoneGap is built.)</p>
  
  <p>Can anyone please help me?
  Thanks.</p>