title: Value of class variable is always null when accessed
body: <p>I am making an api call in a function and updating the value of a class variable (name) in that function. Now, when I check the value of that variable, its fine. But when I try to access it anywhere else in the same class, it returns me nothing. I have tried all possible solutions. Here is the code.</p>
  
  <pre><code>private void PopulateName()
          {
              try
              {
                  string data1 = WebOp.baseUrl1 + "" + Const.action + "=" + Const.productByCategory + "" +
                   "&amp;" + Const.category_id + "=" + category_id;
  
  
                  System.Threading.Tasks.Task.Run(() =&gt;
                  {
  
                      RunOnUiThread(() =&gt; { progressDialog.Show(); });
  
                      WebOp webOp = new WebOp();
                      String str = webOp.doPost1(data1, this);
  
                      JObject jobj = JObject.Parse(str);
  
  
                      string status = jobj[Const.status].ToString();
  
                      if (status.Equals(Const.success))
                      {
                          try
                          {
                              string data = jobj[Const.data].ToString();
                              myDto = JsonConvert.DeserializeObject&lt;List&lt;ProductDto&gt;&gt;(data)[0];
                              name = myDto.thecategory_name;
                              Console.WriteLine("Check value:" + name); //returns the value fine
                              RunOnUiThread(() =&gt;
                              {
  
                                  progressDialog.Dismiss();
                              });
                          }
                          catch (Exception e)
                          {
                              Console.WriteLine(e + "");
                              RunOnUiThread(() =&gt; { progressDialog.Dismiss(); });
                          }
                      }
                      else
                      {
                          RunOnUiThread(() =&gt;
                          {
                              progressDialog.Dismiss();
                          });
                      }
  
  
                  }).ConfigureAwait(false);
              }
              catch (Exception e1)
              {
                  Console.WriteLine(e1 + "");
              }
              Console.WriteLine("Check again:" + name); //returns nothing
          }
  </code></pre>