Should a background worker be a Task or a Thread?

I have a background task or thread which runs an infinite loop. There's an await where it blocks waiting for some input to process.
private async Task MyBackgroundWorker(CancellationToken cancellationToken)
{
    while(!cancellationToken.IsCancellationRequested)
    {
        try
        {
            item = myBlockingCollection.Take(cancellationToken);
            await ProcessItem(item);
        }
        catch (OperationCanceledException)
        {
            return; // cancellationToken was set to Cancelled while waiting for an item.
        }
    }
}

Open in new window

My question is, should I run this as a Task or as a Thread?

Should I run it as
this.cancellationTokenSource = new CancellationTokenSource();
var token = this.cancellationTokenSource.Token;
Task myBackgroundWorker = Task.Run( await () => { MyBackgroundWorker(token); }

Open in new window

Or, I'm starting to think this really isn't a "Task", it's more of a background worker thread, that occasionally gets stopped, and restarted (recreated), and maybe using Task is the wrong approach for this. Maybe this is more properly a Thread:
myThread = new Thread(new ThreadStart(myBackgroundWorker(token));

Open in new window

Should this background worker loop be a Thread or a Task?
deleydSoftware EngineerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
Task.Run will create a new thread (or more appropriately, it will schedule work to the thread pool).

https://msdn.microsoft.com/en-us/library/hh195051(v=vs.110).aspx
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.