title: How to run something in the STA thread?
body: <p>In my WPF application I do some async communication (with server). In the callback function I end up creating InkPresenter objects from the result from server. This requires the running thread to be STA, which apparently it currently isn't. Therefore I get the following exception: </p>
  
  <blockquote>
    <p>Cannot create instance of 'InkPresenter' defined in assembly [..] The calling thread must be STA, because many UI components require this.</p>
  </blockquote>
  
  <p>Currently my async function call is like this: </p>
  
  <pre><code>public void SearchForFooAsync(string searchString)
  {
      var caller = new Func&lt;string, Foo&gt;(_patientProxy.SearchForFoo);
      caller.BeginInvoke(searchString, new AsyncCallback(SearchForFooCallbackMethod), null);
  }
  </code></pre>
  
  <p>How can I make the callback - which will do the InkPresenter creation - be STA? Or invoke the XamlReader parsing in a new STA thread. </p>
  
  <pre><code>public void SearchForFooCallbackMethod(IAsyncResult ar)
  {
      var foo = GetFooFromAsyncResult(ar); 
      var inkPresenter = XamlReader.Parse(foo.Xaml) as InkPresenter; // &lt;!-- Requires STA
      [..]
  }
  </code></pre>