Concurrent blocking Tasks in a BackgroundWorker I'm using a StaTaskScheduler (TPL extension) to open some web browser windows simultaneously and navigate to different sites (using WaitN, but it might as well just be a WebBrowser). 

In my example below I'm running 5 concurrent browsers. Works fine, but it locked the UI thread, so I wrapped my tasks in a BackgroundWorker. Seems like it does the job, but is it the correct way of handling the issue? Do I need to dispose the worker once I'm done? And finally, is lock (ret) the correct way of keeping ret thread safe?

StaTaskScheduler sta = new StaTaskScheduler(5);
BackgroundWorker bw = new BackgroundWorker();

bw.DoWork += (s, ea) =&gt;
{
    List&lt;string&gt; ret = new List&lt;string&gt;();

    lock (ret)

    Task.WaitAll(Util.GetList().Select(row =&gt; Task.Factory.StartNew(() =&gt;
    {

        IEnumerable&lt;string&gt; result = DoUiLockingWork(row.Item1, row.Item2);
        ret.AddRange(result);

    }, CancellationToken.None, TaskCreationOptions.None, sta)).ToArray());

    ea.Result = ret;
};

bw.RunWorkerCompleted += (s, ea) =&gt;
{
    List&lt;string&gt; result = ea.Result as List&lt;string&gt;;

    if (result != null) 
        Debug.WriteLine(result.Count);
};

bw.RunWorkerAsync();
I would go with Task-based method (if you're using .Net 4.5) instead of the BackgroundWorker. That will sort out most of your problems.

Something in the vicinities of 

async Task&lt;List&lt;T&gt;&gt; yourJobAsync(...)
{
    var results = await Task.Run ( () =&gt;
    {
        //your job.
        return jobResults
    });
    return  yourJobAsyncResults
}