title: Cannot convert async lambda expression to delegate type 'Func<bool, string, bool>'
body: <p>I am getting an error with the following code.</p>
  
  <pre><code>public async Task&lt;bool&gt; FlushUrlAsync(Uri url, bool recursive, CancellationToken token = default(CancellationToken))
  {
      _serverPortsConfig.CacheServerPorts
          .Select(cacheServerPort =&gt; $"http://{url.Host}:{cacheServerPort}{url.AbsolutePath}")
          .Aggregate(true, (current, memoryCacheUrl) =&gt; current &amp;&amp; await FlushUrlAsync(recursive, memoryCacheUrl)); //&lt;--- produces the next error:
      // Cannot convert async lambda expression to delegate type
      // 'Func&lt;bool, string, bool&gt;'. An async lambda expression may return 
      // void, Task or Task&lt;T&gt;, none of which are convertible to
      // 'Func&lt;bool, string, bool&gt;'.
   }
  </code></pre>
  
  <p>This method calls the following function</p>
  
  <pre><code>private async Task&lt;bool&gt; FlushUrlAsync(bool recursive, string memoryCacheUrl)
  {
      return await someMagic(); //for clearity I removed the code.
  }
  </code></pre>
  
  <p>It looks a lot like: <a href="https://stackoverflow.com/questions/17226284/convert-async-lambda-expression-to-delegate-type-system-funct">Convert async lambda expression to delegate type System.Func&lt;T&gt;?</a>, howevery, there solution won't /can't get it to work for me.</p>
  
  <p>I had:</p>
  
  <pre><code>var result = true;
  foreach (var cacheServerPort in _serverPortsConfig.CacheServerPorts)
  {
      var memoryCacheUrl = $"http://{url.Host}:{cacheServerPort}{url.AbsolutePath}";
      result = result &amp;&amp; await FlushUrlAsync(memoryCacheUrl, recursive);
  }
  
  return result;
  </code></pre>
  
  <p>Then resharper gave me the code that is provided, but just adding the async keyword doesn't work.</p>
  
  <pre><code>.Aggregate(true, async (current, memoryCacheUrl) =&gt; current &amp;&amp; await FlushUrlAsync(recursive, memoryCacheUrl));
  </code></pre>
  
  <p>will give me the erorr: the return type of async method must be void, task or Task.</p>
  
  <p>any ideas?</p>