title: Why does Task.WaitAll() not block or cause a deadlock here?
body: <p>In the example below two <code>await</code> calls are used. To gain performance, the sample gets converted <code>Task.WaitAll()</code> instead (not really any faster, but this is just an example).</p>
  
  <p>This is code from a library using Sqlite.Net on Android and the method gets called from <code>OnResume()</code> on the main UI thread:</p>
  
  <pre><code>public async Task SetupDatabaseAsync()
  {
    await CreateTableAsync&lt;Session&gt;();
    await CreateTableAsync&lt;Speaker&gt;();
  }
  </code></pre>
  
  <p>Here's the alternative:</p>
  
  <pre><code>public void SetupDatabaseAsync()
  {
    var t1 = CreateTableAsync&lt;Session&gt;();
    var t2 = CreateTableAsync&lt;Speaker&gt;();
  
    Task.WaitAll(t1, t2);
  }
  </code></pre>
  
  <p>But from my understanding <code>Task.WaitAll()</code> should block the UI thread while waiting, thus leading to a deadlock. But it works just fine. Is that because the two calls don't actually invoke anything on the UI thread?</p>
  
  <p>What's the difference if I use <code>Task.WhenAll()</code> instead? My guess it that it would work even if the UI thread would be invoked, just like with <code>await</code>.</p>