title: Task.Factory.StartNew freezing the UI
body: <p>In the below code when I am scheduling new Task (Task.Factory.StartNew), it is freezing UI. Can anyone help me to understand what's wrong here.</p>
  
  <pre><code>public Task ShowHierarchy(IHierarchyFilterStrategy topHierarchyStrategy, IHierarchyFilterStrategy bottomHierarchyStrategy)
  {
        IEnumerable&lt;IHierarchyNodeViewModel&gt; topList = null;
        IEnumerable&lt;IHierarchyNodeViewModel&gt; bottomList = null;
        var context = TaskScheduler.FromCurrentSynchronizationContext();
        var task = Task.Factory.StartNew(() =&gt;
        {
            topList = topHierarchyStrategy != null ? topHierarchyStrategy.RetrieveHierarchy().ToList() : null;
            bottomList = bottomHierarchyStrategy != null
                 ? bottomHierarchyStrategy.RetrieveHierarchy().ToList()
                 : null;
        });
  
        return task.ContinueWith((antecedent) =&gt;
        {
            View.SetAvailableNodes(topList, bottomList);
        }, context);
  }
  </code></pre>
  
  <p>EDIT:
  to be more specific... my UI is getting block on </p>
  
  <pre><code>topList = topHierarchyStrategy != null ? topHierarchyStrategy.RetrieveHierarchy().ToList() : null;
  </code></pre>
  
  <p>RetrieveHierarchy() method is to load some data from cache if not in cache then go to DB to get the data. it has nothing to do with UI.  </p>
  
  <p>To summrize, what I am doing here is, I am getting two lists from cache/DB in first task and in second task, using these two values to update the UI (some tree nodes). but UI freeze only when it try to retrive value from RetrieveHierarchy() method in the first line, no where else.</p>
  
  <p>The issue occured only first time when data comes from DB. Once it is loaded in cache, no time taken by this line/no UI frozon. </p>
  
  <p>using below line to call ShowHierarchy() method</p>
  
  <p>ShowHierarchy(topHierarchyStrategy, bottomHierarchyStrategy);</p>
  
  <p>I am not using it's return value anywhere.</p>