<p>In my application I am using <a href="https://github.com/kubernetes-client/csharp" rel="nofollow noreferrer">c# kubernetes client</a>. I need to use Task.WhenAll but everytime namespaces is different and it fails compiling.</p>
<pre><code> var configMap = await client.ListConfigMapForAllNamespacesAsync(cancellationToken: cancellationToken);
 var secret = await client.ListSecretForAllNamespacesAsync(cancellationToken: cancellationToken);
 var service = await client.ListServiceForAllNamespacesAsync(cancellationToken: cancellationToken);
 var pvc = await client.ListPersistentVolumeClaimForAllNamespacesAsync(
                    cancellationToken: cancellationToken);
 var deployment = await client.ListDeploymentForAllNamespacesAsync(cancellationToken: cancellationToken);
 var sts = await client.ListStatefulSetForAllNamespacesAsync(cancellationToken: cancellationToken); // var is V1StatefulSetList
 var daemonSet = await client.ListDaemonSetForAllNamespacesAsync(cancellationToken: cancellationToken); // var is V1DaemonSetList (and it is same for appropriate namespaces)

 Task.WhenAll(configMap, secret,service,pvc,deployment,sts,daemonSet); // I would like use like this
</code></pre>
<p>Simply I would like call all async actions as Paralelly or call using Task.WhenAll</p>

Arzu Suleymanov
<p>By using <code>await</code> every call is made and completed before the next runs. So, just remove the awaits and then you have a bunch of <code>Task</code>s which you can wait all:</p>
<pre><code>var configMap = client.ListConfigMapForAllNamespacesAsync(cancellationToken: cancellationToken);
var secret = client.ListSecretForAllNamespacesAsync(cancellationToken: cancellationToken);
var service = client.ListServiceForAllNamespacesAsync(cancellationToken: cancellationToken);
var pvc =  client.ListPersistentVolumeClaimForAllNamespacesAsync( cancellationToken: cancellationToken);
var deployment = client.ListDeploymentForAllNamespacesAsync(cancellationToken: cancellationToken);
var sts =  client.ListStatefulSetForAllNamespacesAsync(cancellationToken: cancellationToken); // var is V1StatefulSetList
var daemonSet = client.ListDaemonSetForAllNamespacesAsync(cancellationToken: cancellationToken); // var is V1DaemonSetList (and it is same for appropriate namespaces)

var result = await Task.WhenAll(configMap, secret,service,pvc,deployment,sts,daemonSet);
</code></pre>
<p>by <code>await</code>ing the <code>WhenAll</code> you can wait until all the tasks have completed.</p>
