Async/Await not working as expected
<p>I wanted to call / run three tasks parallely and then wait for their results. From my service class what I did is ...</p>

<pre><code>        var _validChapterCodesTask = gd.validateChapterCodeDetails(_input1);

        var _validGroupCodesTask = gd.validateGroupCodeDetails(_input1); 

        await Task.WhenAll(_validChapterCodesTask, _validGroupCodesTask);

        var _validChapterCodes = await _validChapterCodesTask;

        var _validGroupCodes = await _validGroupCodesTask;
</code></pre>

<p>And in my DAL Class , the definitions look like :</p>

<pre><code>   public async Task&lt;IEnumerable&lt;ChapterCodeValidationOutput&gt;&gt; validateChapterCodeDetails(GroupMembershipValidationInput gmvi)
    {
        Repository rep = new Repository();
        if (!gmvi._chapterCodes.All(x =&gt; x.Equals("")))
        {
            var _validChapterCodes = await rep.ExecuteSqlQueryAsync(typeof(ChapterCodeValidationOutput),SQL.Upload.UploadValidation.getChapterCodeValidationSQL(gmvi._chapterCodes), null);
            return (IEnumerable&lt;ChapterCodeValidationOutput&gt;)_validChapterCodes;
        }
        else
            return new List&lt;ChapterCodeValidationOutput&gt;();
    }


    public async Task&lt;IEnumerable&lt;GroupCodeValidationOutput&gt;&gt; validateGroupCodeDetails(GroupMembershipValidationInput gmvi)
    {
        Repository rep = new Repository();
        if (!gmvi._chapterCodes.All(x =&gt; x.Equals("")))
        {
            var _validGroupCodes = await rep.ExecuteSqlQueryAsync(typeof(GroupCodeValidationOutput), SQL.Upload.UploadValidation.getGroupCodeValidationSQL(gmvi._groupCodes), null);
            return (IEnumerable&lt;GroupCodeValidationOutput&gt;)_validGroupCodes;
        }
        else
            return new List&lt;GroupCodeValidationOutput&gt;();
    }
</code></pre>

<p>But these are not working as expected ? The breakpoints hit show that one by one the method is getting called from service, going to DAL, execute the DB Query and comeback and assign to respective variables.</p>

<p>And as soon as it hits </p>

<pre><code>await Task.WhenAll(_validChapterCodesTask, _validGroupCodesTask);
</code></pre>

<p>The next few lines are not hit and the control returns to the invoking controller.</p>

<p>How would I get back their results and fire them parallely and wait for their results only?</p>

<p>What am I doing wrong ?</p>