title: How to call an async method in viewmodel
body: <p>I'm trying to learn MVVM pattern in WPF application. I wrote this async method in my viewmodel (it has to be async since I'm using HttpClient and it's methods are async):</p>
  
  <pre><code>public async Task&lt;Dictionary&lt;int, BusStop&gt;&gt; GetBusStops()
      {
          var busStopDict = new Dictionary&lt;int, BusStop&gt;();
          var url = "my url";
  
          using (HttpClient client = new HttpClient())
          using (HttpResponseMessage response = await client.GetAsync(url))
          using (HttpContent content = response.Content)
          {
              string data = await content.ReadAsStringAsync();
              var regularExpression = Regex.Match(data, "\\[(.)*\\]");
              var result = regularExpression.Groups[0];
  
              var json = JValue.Parse(result.ToString());
              var jsonArray = json.ToArray();
  
              foreach (var a in jsonArray)
              {
                  // irrelevant logic
  
                  busStopDict.Add(nr, bs);
              }
          }
  
          return busStopDict;
      }
  </code></pre>
  
  <p>This methods returns a dictionary filled with bus stops (my model). I would like to bind this dictionary with combobox in view, but I can't get it work, because I can't call this async method in constructor of my viewmodel and I have no idea where can I call it. Do you have any suggestions?</p>