Showing tag results for Task Parallel Library

Oct 21, 2010
Post comments count0
Post likes count0

New Feature? :: ThreadLocal.Values

Danny Shih

We’ve been considering adding a Values property to System.Threading.ThreadLocal<T>.  Values would return a collection of all current values from all threads (e.g. what you’d get if you evaluated Value from each thread).  This would allow for easy aggregations, and in fact in our Parallel Extensions Extras we have a wrapp...

.NET Parallel Programming
Oct 15, 2010
Post comments count0
Post likes count0

FAQ :: StartNew() with TaskScheduler.FromCurrentSynchronizationContext() doesn’t work?

Danny Shih

We’ve seen a number of folks write the following code to execute on the UI thread and get unexpected behavior. TaskScheduler uiScheduler = TaskScheduler.FromCurrentSynchronizationContext();Task uiTask = Task.Factory.StartNew(delegate{    // … Update UI component; BUG!}, uiScheduler);The issue is that the StartNew ca...

.NET Parallel Programming
Oct 7, 2010
Post comments count0
Post likes count0

Creating pre-completed Tasks

Danny Shih

 We’ve been considering adding support for creating completed Tasks from an existing result.  Here’s a prototypical example of where this could be valuable. void Task<float> ComputeAsync(...) {     if (!resultIsCached)     {         return Task<floa...

.NET Parallel Programming
Aug 5, 2010
Post comments count0
Post likes count0

FAQ :: TaskScheduler.UnobservedTaskException event doesn’t work?

Danny Shih

Recall that if exceptions thrown from Task bodies are left unobserved, they will be escalated.  In .NET 4, this means that TPL will throw them on the finalizer after the Task objects are available for garbage collection.  The UnobservedTaskException event on the TaskScheduler class was added as a last-resort method to observe such excepti...

.NET Parallel Programming
Jun 30, 2010
Post comments count0
Post likes count0

PLINQ and Office Add-ins

Igor Ostrovsky - MSFT

Many different kinds of applications can benefit from multi-core parallelism, including add-ins to Microsoft Office. Donny Amalo wrote a paper, PLINQ and Office Add-ins, where he demonstrates how to implement two parallel Microsoft Office add-ins using PLINQ: (This paper and many more are available through the Parallel Computing Developer C...

.NET Parallel Programming
Jun 28, 2010
Post comments count0
Post likes count0

Integrating Parallelism with Windows Workflow Foundation

Igor Ostrovsky - MSFT

Despite the similarity in naming, the System.Threading.Tasks.Parallel class and the System.Activities.Statements.Parallel* activities in WF4 are largely orthogonal in the scenarios they address. However, WF4 activities and the new parallel programming types in .NET 4 can be used together to great advantage.Ling Wo and Cristina Manu wrote a pap...

.NET Parallel Programming
Jun 13, 2010
Post comments count1
Post likes count0

“Task.Factory.StartNew” vs “new Task(…).Start”

Stephen Toub - MSFT

With TPL, there are several ways to create and start a new task.  One way is to use the constructor for task followed by a call to the Start method, e.g.        new Task(...).Start();and the other is by using the StartNew method of TaskFactory, e.g.        Task.Factory.StartNew(....

.NET Parallel Programming
May 25, 2010
Post comments count0
Post likes count0

Lesser-known Multi-threaded Debugging Support in Visual Studio 2010

Stephen Toub - MSFT

We’ve been very excited about the new debugging windows in Visual Studio 2010, namely Parallel Tasks and Parallel Stacks, as well as the newly revamped Threads window, and thus we’ve talked about them quite a bit. For an overview, you can read the MSDN Magazine article at https://msdn.microsoft.com/en-us/magazine/ee410778.aspx, and Daniel Moth has ...

.NET Parallel Programming
May 24, 2010
Post comments count0
Post likes count1

Why is TaskContinuationsOptions.ExecuteSynchronously opt-in?

Stephen Toub - MSFT

For a relatively advanced feature, I've been surprised how often this question has come up recently. When a task completes, its continuations become available for execution, and by default, a continuation will be scheduled for execution rather than executed immediately.  This means that the continuation has to be queued to the scheduler a...

.NET Parallel Programming
May 4, 2010
Post comments count0
Post likes count0

ParallelExtensionsExtras Tour – #16 – Async Tasks for WebClient, SmtpClient, and Ping

Stephen Toub - MSFT

(The full set of ParallelExtensionsExtras Tour posts is available here.) The Task Parallel Library isn’t just about CPU-bound operations.  The Task class is a great representation for any asynchronous operation, even those implemented purely as asynchronous I/O.Task’s ability to represent arbitrary asynchronous operations without...

.NET Parallel Programming