title: Writing multithreaded methods using async/await in .Net 4.5
body: <p>I have a small query.</p>
  
  <p>I admit that I haven't use multithreading much before .Net 4.5, but with the new <code>async/await</code> functionality I decided to give it a try. I started experimenting with it and all seems fine, but I wasn't able to find a solution for my "problem" anywhere on the web. </p>
  
  <p>So everyone explain how <code>await</code> can be used with the newly transformed methods of the .Net platform (e.g. <code>WriteAsync()</code>, <code>ReadAsync()</code> etc...), but what if I wanted to use it for my own methods? For example, lets say that I am performing an extremely expensive calculation and want all of my 4 cores working on it. I would have something similar to this:</p>
  
  <pre><code>async Task DoLotsOfWork&lt;T&gt;(T[] data, int start, int end)
  {
      //Do very expensive work
  }
  </code></pre>
  
  <p>But since I don't have an <code>await</code> keyword there, the method is just treated as a synchronous one. I would like to call it 4 times from outside so that it can run on all of my cores, while I display something sensible  to the user(e.g. "Please wait..."). The only solution that I was able to figure out was to add a <code>await Task.Yield();</code> in the start of the method. Something like this:</p>
  
  <pre><code>async Task DoLotsOfWork&lt;T&gt;(T[] data, int start, int end)
  {
      await Task.Yield();
      //Do very expensive work
  }
  </code></pre>
  
  <p>In that case, the method would behave as I would expect it to. But is there a better solution for this? I feel that it should be easier/more sensible than writing exactly that line of code. I understand that I can create a <code>Task/Thread</code> object and call the <code>Start()</code> method, but that requires even more work. I just thought that with the new async/await functionality this sort of thing would be easier. </p>