Top "Task-parallel-library" questions

The Task Parallel Library is part of the .NET Framework since .NET 4. It is a set of APIs to enable developers to program asynchronous applications.

Set ApartmentState on a Task

I am trying to set the apartment state on a task but see no option in doing this. Is there …

c# task task-parallel-library
Default parameter for CancellationToken

I have some async code that I would like to add a CancellationToken to. However, there are many implementations where …

c# asynchronous task-parallel-library cancellation-token
Does the use of async/await create a new thread?

I am new to TPL and I am wondering: How does the asynchronous programming support that is new to C# 5.0 (…

c# multithreading async-await task-parallel-library c#-5.0
How to construct a Task without starting it?

I want to use this Task<TResult> constructor. I can't seem to get the syntax right. Could someone …

c# task-parallel-library async-await
Parallel.ForEach can cause a "Out Of Memory" exception if working with a enumerable with a large object

I am trying to migrate a database where images were stored in the database to a record in the database …

c# out-of-memory task-parallel-library large-data
How to Mock a Task<> Result?

I'm setting up some unit tests and using Rhino Mocks to populate the object being tested. One of the things …

c# task-parallel-library rhino-mocks
Is it considered acceptable to not call Dispose() on a TPL Task object?

I want to trigger a task to run on a background thread. I don't want to wait on the tasks …

c# .net multithreading dispose task-parallel-library
Throw Exception inside a Task - "await" vs Wait()

static async void Main(string[] args) { Task t = new Task(() => { throw new Exception(); }); try { t.Start(); t.Wait(); } catch (…

c# exception-handling task-parallel-library async-await parallel-extensions
classic producer consumer pattern using blockingcollection and tasks .net 4 TPL

Please see below pseudo code //Single or multiple Producers produce using below method void Produce(object itemToQueue) { concurrentQueue.enqueue(itemToQueue); …

c# multithreading scheduled-tasks task-parallel-library pfx
multiple awaits vs Task.WaitAll - equivalent?

In terms of performance, will these 2 methods run GetAllWidgets() and GetAllFoos() in parallel? Is there any reason to use one …

c# .net async-await task-parallel-library