title: How to properly use async/await in .NET 4.0
body: <p>for some reasons i needed to go back version of .net, so i was 4.5 and now im 4.0, and im having conflict with my async methods:
  i have wcf service, and i want to execute the async methods and await them, so in 4.5 i did this: 
  wcf:</p>
  
  <pre><code>public async Task&lt;DataTable&gt; ProcessSomething(string Param1, int Param2)
          {
              return await Task.Run(() =&gt;
              { 
              return new DataTable("aaa");
              });
          }
  </code></pre>
  
  <p>and 4.5 client:</p>
  
  <pre><code>private static async Task&lt;bool&gt; ProcessSomethingAsync(string Param1, int Param2)
          {
              decimal payin = 0;
              Task&lt;DataTable&gt; result = Client.Instance.___Client.ProcessSomethingAsync(Param1, Param2);
              if (result == await Task.WhenAny(result, Task.Delay(1000)))
              {
                  //code here..
              }
          }   
  </code></pre>
  
  <p>but when i reverted to 4.0, both, the service and the client, i had to use nuget library: </p>
  
  <blockquote>
    <p><a href="https://www.nuget.org/packages/Microsoft.Bcl.Async/" rel="nofollow noreferrer">https://www.nuget.org/packages/Microsoft.Bcl.Async/</a></p>
  </blockquote>
  
  <p>now in wcf 4.0 i have this:</p>
  
  <pre><code>public async Task&lt;DataTable&gt; ProcessSomething(string Param1, int Param2)
          {
              return await Task.Factory.StartNew(() =&gt; 
              {
                  return new DataTable("aaa");
              });
          }
  </code></pre>
  
  <p>and in client i try this:</p>
  
  <pre><code>DataTable ProcessSomethingResult = await Client.Instance.____Client.ProcessSomethingAsync(Param1, Param2);
  </code></pre>
  
  <p>but error pops up saying: cannot await void...
  if i call:</p>
  
  <pre><code>DataTable ProcessSomethingResult = Client.Instance.____Client.ProcessSomething(Param1, Param2);
  </code></pre>
  
  <p>it returns datatable no problem ... but async is returning void .. why ? and how to solve this ... tnx in advance..</p>
  
  <p>//in comments you asked me for the definition of process something, here it is:</p>
  
  <pre><code>public async Task&lt;DataTable&gt; ProcessTicket(string Barcode, int ClientID)
          {
              return await Task.Factory.StartNew(() =&gt; 
              {
                  try
                  {
                      DataTable dt = new DataTable("ProcessTicket");
                      using (SqlConnection con = new SqlConnection(TempClass._DatabaseConnectionString))
                      {
                          using (SqlCommand com = new SqlCommand("SELECT * FROM dbo.ProcessTicket(@Barcode, @ClientID)", con))
                          {
                              con.Open();
                              com.CommandType = CommandType.Text;
                              com.Parameters.AddWithValue("@Barcode", Barcode);
                              com.Parameters.AddWithValue("@ClientID", ClientID);
                              dt.Load(com.ExecuteReader());
                              if (dt == null)
                                  throw new FaultException("DataTable from database is null.");
                              return dt;
                          }
                      }
                  }
                  catch (Exception ex)
                  {
                      Logs.Instance.AppendLogs(ex.Message, MethodBase.GetCurrentMethod().Name);
                      throw new FaultException(ex.Message);
                  }
              });
          }
  </code></pre>