title: Writing async monotouch code
body: <p>So I have a method that must execute three tasks. 
  The first task must be completed before the other two, which can be executed in parallel.
  This is what I have right now (modified for simplicity)</p>
  
  <pre><code>void facebookButtonClicked (object sender, EventArgs e)
          {
              View.Add (loadingOverlay);
              AppDelegate.MobileService = new MobileServiceClient ("myserverUrl", "myApiKey");
              var users= AppDelegate.MobileService.GetTable&lt;User&gt; ();
              var identities= AppDelegate.MobileService
                  .GetTable ("Identities");
              AppDelegate.MobileService
                  .LoginAsync (this, MobileServiceAuthenticationProvider.Facebook)
                      .ContinueWith (t =&gt; {
                  if (t.Status == TaskStatus.RanToCompletion) {
                              AppDelegate.mobileServiceUser = t.Result;
                              var task1 = users.InsertAsync(new User{BirthDate = DateTime.Now});
                              var task2 = identities.ReadAsync("");
                              Task.Factory.ContinueWhenAll(new Task[]{task1,task2},_=&gt;{
                                  if(task1.Status==TaskStatus.RanToCompletion &amp;&amp; task2.Status== TaskStatus.RanToCompletion)
                                  {
                                      var token = task2.Result
                                          .GetArray()[0]
                                          .GetObject ()
                                          .GetNamedObject ("identities")
                                          .GetNamedObject ("facebook")
                                          .GetNamedString ("accessToken");    
  
                                  SaveAuthorization (token);
                                  NavigationController.PushViewController (new TabBarController (), false);
                                  }
                              });             
                          }});
          }
  </code></pre>
  
  <p>The problem is (other than Im a newb at async code) that when it tries to execute "PushViewController" I get:</p>
  
  <blockquote>
    <p>UIKit.UIKitThreadAccessException: UIKit Consistency error: you are
    calling a UIKit method that can only be invoked from the UI thread</p>
  </blockquote>
  
  <p>How can I refactor/modify this code to fix it?
  please help.</p>