title: Task.WhenAll taking a long time to return
body: <p>I have a kiosk C# application in the field where we're trying to provide a consistent end-user experience.  Part of that is showing a brief "processing" screen for a minimum of 2 seconds while we do any server communication, since we're running over a 3G network.  Here's the code I'm using:</p>
  
  <pre><code>Stopwatch sw = new Stopwatch();
  sw.Start();
  
  Task t1 = Task.Delay(2000);
  Task&lt;Customer&gt; t2 = Task.Run&lt;Customer&gt;(() =&gt;
  {
      return _client.LookupCustomer(cardNumber, pin);
  });
  
  await Task.WhenAll(t1, t2);
  customer = t2.Result;
  sw.Stop();
  Log.InfoFormat("Time for ValidateCustomer {0}", sw.Elapsed.ToString());
  </code></pre>
  
  <p>Here is the code for <code>LookupCustomer</code>.  The "PayStationClient" constructor is empty, so there is no more hidden logic except what WCF does under the scenes.</p>
  
  <pre><code>    public DTO.Customer LookupCustomer(string cardNumber, string PIN)
      {
          PayStationClient client = new PayStationClient();
          decimal accountBalance, availableWithdrawalAmount, maxDailyWithdrawalAmount;
  
          Stopwatch sw = new Stopwatch();
          sw.Start();
  
          bool isValid = client.ValidatePin(cardNumber, PIN, out accountBalance, out availableWithdrawalAmount, out maxDailyWithdrawalAmount);
  
          sw.Stop();
          Log.InfoFormat("Time for LookupCustomer {0}", sw.Elapsed.ToString());
  
          DTO.Customer customer = new DTO.Customer()
          {
              ResponseStatus = (isValid) ? null : new ResponseStatus("Invalid PIN"),
              AccountBalance = accountBalance,
              AvailableWithdrawalAmount = availableWithdrawalAmount,
              MaxDailyWithdrawalAmount = maxDailyWithdrawalAmount,
              CardNumber = cardNumber
          };
  
          return customer;
      }
  </code></pre>
  
  <p>The problem is that my logs show this taking >20-30 seconds, while separate logging (client-side) in the <code>LookupCustomer</code> show the server call is returning in &lt; 1-2 seconds.  Where does all the extra time go?  What am I missing with the <code>WhenAll</code>?</p>
  
  <p><strong>I forgot to mention</strong> that when the kiosk first goes online, it seems to behave as expected.  Its only after its been running for a while - 8+ hours - that the slowdown starts.  After a reboot, we're back to normal.  </p>
  
  <p>These kiosks have been deployed for several months, and we just added the asynchronous logic this week.  We've never had a server-side slow-down before.  Its like <em>something</em> in the first snippet is what did it.</p>