title: How to Stop loop inside while
body: <pre><code>  public void ChangeDailyTasks()
    {
          gameManager.ActiveTasks.today = gameManager.DateTimeNow();
          gameManager.ActiveTasks.Dailytasks = new List&lt;Task&gt;();
          while (gameManager.ActiveTasks.Dailytasks.Count != 5)
          {
              var addingTask = gameManager.TaskList[UnityEngine.Random.Range(0, 
              gameManager.TaskList.Count)];
              foreach (Task i in gameManager.ActiveTasks.Dailytasks)
                  if (i.name != addingTask.name)
                      gameManager.ActiveTasks.Dailytasks.Add(addingTask);
          }
  }
  </code></pre>
  <p>If I call This function my computer is freezing What i doing is not correctly I just wanna Add 5 new Elements  Inside  List gameManager.ActiveTasks.Dailytasks. Thank you !</p>