update UI in Task using TaskScheduler.FromCurrentSynchronizationContext <p>I want to add some text to list box using <code>Task</code> and I simply use a button and place in click event this code:</p> <pre><code>TaskScheduler uiScheduler = TaskScheduler.FromCurrentSynchronizationContext(); Task.Factory.StartNew(() =&gt; { for (int i = 0; i &lt; 10; i++) { listBox1.Items.Add("Number cities in problem = " + i.ToString()); System.Threading.Thread.Sleep(1000); } }, CancellationToken.None, TaskCreationOptions.None, uiScheduler); </code></pre> <p>but it does not work and UI locked until the end of the for loop.</p> <p>Where is the problem ?</p> <p>thanks :)</p>