title: Xamarin & RestSharp - Async call hangs/never returns
body: <p>I am writing an Android app in Xamarin to perform an async json call using restsharp. My setup involves an android java bindings library (jar file converted to c#). This library has one class that subclasses Application and looks something like this </p>
  
  <p>HealthData.java (which is part of jar and referenced into the app as project) Intent is to run this before any activities are loaded.</p>
  
  <pre><code>import android.app.Application;
  
  public class HealthData extends Application {
      private int intTest;
  
      HealthData () {
          intTest = 0;
      }
  
      public int getIntTest(){
          return intTest;
      }
  
      public void setIntTest(int value){
          intTest = value;
      }
  }
  </code></pre>
  
  <p>I am loading this subclass in AndroidManifest.xml as below -</p>
  
  <pre><code>&lt;application android:label=“demo" android:name=“.HealthData"&gt;
          &lt;activity android:name=“.MainActivity" &gt;
               &lt;intent-filter&gt;
                   &lt;action android:name="android.intent.action.MAIN" /&gt;
                   &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
               &lt;/intent-filter&gt;
           &lt;/activity&gt;
      &lt;/application&gt;
  </code></pre>
  
  <p>And my mainactivity (written in c#) which performs async call looks like this -</p>
  
  <pre><code>using RestSharp;
  
  namespace demo
  {
      [Activity (Label = "demo", MainLauncher = true, Icon = "@drawable/icon")]
      public class MainActivity : Activity
      {
          static string TAG = "PRINT-ME";
  
          protected override void OnCreate (Bundle bundle)
          {
              base.OnCreate (bundle);
  
              // Set our view from the "main" layout resource
              SetContentView (Resource.Layout.Main);
  
              callme();
  
              Log.Info (TAG, "callme returns");
          }
  
          private async void callme()
          {
              // Call the method that runs asynchronously.
              string result = await WaitAsynchronouslyAsync();
  
              // Display the result.
              TextView txt = FindViewById&lt;TextView&gt; (Resource.Id.textViewAsync);
              txt.Text = result;
          }
  
          public async Task&lt;string&gt; WaitAsynchronouslyAsync()
          {
              // fetch some json via restsharp
              var client = new RestClient ("http://rxnav.nlm.nih.gov/REST/RxTerms/rxcui/");
              var request = new RestRequest (String.Format ("{0}/allinfo", "198440"));
  
              Log.Info (TAG, "before awaiting");
  
              // ExecuteTaskSync
              IRestResponse resp = await ExecuteTaskAsync (client, request);
  
              return resp.Content;
          }
  }
  </code></pre>
  
  <p>Problem - ExecuteTaskAsync blocks/never returns when I use HealthData in manifest file. If I skip loading HealthData in AndroidManifest.xml, async call returns and everything is fine.</p>
  
  <p>Any idea why the async call fails when I use HealthData? I don't see any errors or warnings from the logcat.</p>
  
  <p>I have tried with c# version of HealthData and used it in Manifest.xml and async call works FINE.</p>