'Why are some of task are not being executed? [duplicate]

I have this Code below that runs in a Task. I want my program to more responsive but when I try to run the code below. Some of the task are successfully completed.

   private async void SaveRecordToDB()
    {
        List<Task> listOfTask = new List<Task>();
        for (int i = 0; i <= 15; i++)
        {
            listOfTask.Add(Task.Run(() => IterateRowsSaving(i)));

        }

        await Task.WhenAll(listOfTask);
    }

    private bool IterateRowsSaving(int index)
    {
        bool Success = true;
        //Save to Database
        //Assuming that every iteration has a long operation running
        return Success;
    }

What could have been that I have done wrong?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source