title: Is Task.Run or Task.Factory.StartNew are bad practice for windows phone or any other client platform?
body: <p>I have WP 8.1 app that using web service a lot, and I want to keep it as much responsive as possible. From iOS dev expierense - there is one strict rule: "Do not do in UI thread any complex calculations! Doesnt matter how you will reach this: with blocks or with GCD".</p>
  
  <p>Problem that not all API has async versions, e.g. JSON.NET, SQLite or any own complex algorithm in the app. I have read a lot of <a href="http://blogs.msdn.com/b/pfxteam/archive/2012/03/24/10287244.aspx" rel="nofollow">articles</a> that are defining Task.Run and Task.Factory.StartNew as bad practice + <a href="https://github.com/JamesNK/Newtonsoft.Json/issues/66" rel="nofollow">this</a>.</p>
  
  <p>So, is it good to write code like this? Will it cause some cpu overloading/battery drain/stability issues? If async wrappers are bad idea - what is the right way to make complex operations async(background thread)?</p>
  
  <pre><code> protected async Task&lt;T&gt; GetDataAsync&lt;T&gt;(string uriString, CancellationToken cancellationToken = default(CancellationToken))
      {
          var uriToLoad = new Uri(uriString);
          using (var httpClient = new HttpClient())
          {
              var response= await httpClient.GetAsync(uriToLoad, cancellationToken).ConfigureAwait(false);
              response.EnsureSuccessStatusCode();
              cancellationToken.ThrowIfCancellationRequested();
  
              var dataString = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
              cancellationToken.ThrowIfCancellationRequested();
  
              // async wrapped call to sync API
              var result = await Task.Factory.StartNew(() =&gt; JsonConvert.DeserializeObject&lt;T&gt;(dataString), cancellationToken).ConfigureAwait(false);
              cancellationToken.ThrowIfCancellationRequested();
  
              return result;
          }
      }
  </code></pre>