task-parallel-library

Support of progress reporting and incremental results in .NET 4.0 "Task Parallel Library"

I know that Task Parallel Library is still in Beta and there are likely to be less resources available but from whatever I have read, library gives very special treatment to task scheduling, exception handling and cancellation. But I don't find any references to progress reporting and sending incremental results from tasks. These 2 thin...

Is there a way to tell which Tasks are currently running in Task Parallel Library

I can't see a way to see which tasks are running. There is the Task.Current property, but what if there are multiple tasks running? Is there a way to get this kind of information? Alternately, is there a built in way to get notified when a task starts or completes? ...

f# Task Parallel Library vs Async Workflows

I have some stuff written in c# that executes concurrent code, making heavy use of the Task Parallel Library (Task and Future continuation chains). I'm now porting this to F# and am trying to figure out the pros and cons of using F# Async workflows vs. the constructs in the TPL. I'm leaning towards TPL, but I think it could be done e...

Reactive Framework vs PLINQ vs Task Parallel Library vs Parallel Extensions

In a few words, can anyone set the record straight what is what? Does this all end up in .NET 4.0 ? ...

Is it too early to start designing for Task Parallel Library?

I have been following the development of the .NET Task Parallel Library (TPL) with great interest since Microsoft first announced it. There is no doubt in my mind that we will eventually take advantage of TPL. What I am questioning is whether it makes sense to start taking advantage of TPL when Visual Studio 2010 and .NET 4.0 are relea...

Does Parallel.ForEach require AsParallel()

ParallelEnumerable has a static member AsParallel. If I have an IEnumerable<T> and want to use Parallel.ForEach does that imply that I should always be using AsParallel? e.g. Are both of these correct (everything else being equal)? without AsParallel: List<string> list = new List<string>(); Parallel.ForEach<string>(GetFileList().Where...

Can CancellationTokens be used across AppDomains

.NET 4 introduced some types to nicely support cooperative cancellation. I would like to be able to cancel an operation which is running in a different AppDomain. The CancellationToken type is a struct. If I pass it to another AppDomain, will it work as normal? ...

How does Task Parallel Library scale on a terminal server or in a web application?

I understand that the TPL uses work-stealing queues for its tasks when I execute things like Parallel.For and similar constructs. If I understand this correctly, the construct will spin up a number of tasks, where each will start processing items. If one of the tasks complete their allotted items, it will start stealing items from the o...

Can .NET Task instances go out of scope during run?

If I have the following block of code in a method (using .NET 4 and the Task Parallel Library): var task = new Task(() => DoSomethingLongRunning()); task.Start(); and the method returns, will that task go out of scope and be garbage collected, or will it run to completion? I haven't noticed any issues with GCing, but want to make sur...

Mock Assertions on objects inside Parallel ForEach's???

Any idea how we can assert a mock object was called when it is being accessed inside Parallel.ForEach via a closure? I assume that because each invocation is on a different thread that Rhino Mocks loses track of the object? Pseudocode: var someStub = MockRepository.GenerateStub() Parallel.Foreach(collectionOfInts, anInt => someStub.Do...

Parallel loops and Random produce odd results

I just started playing with the Task Parallel Library, and ran into interesting issues; I have a general idea of what is going on, but would like to hear comments from people more competent than me to help understand what is happening. My apologies for the somewhat lengthy code. I started with a non-parallel simulation of a random wal...

Does my GetEnumerator cause a deadlock?

I am starting to write my first parallel applications. This partitioner will enumerate over a IDataReader pulling chunkSize records at a time from the data-source. TLDR; version private object _Lock = new object(); public IEnumerator GetEnumerator() { var infoSource = myInforSource.GetEnumerator(); //Will this ca...

'foreach' failing when using Parallel Task Library

The following code creates the correct number of files, but every file contains the contents of the first list. Can anyone spot what I've done wrong please? private IList<List<string>> GetLists() { // Code omitted for brevity... } private void DoSomethingInParallel() { var lists = GetLists(); var tasks = new List<Task>(); var...

Can I use the task parallel library in a .Net 3.5 project?

I heard that the Task Parallel Library can be used in a .Net 3.5 project. Is this correct, and if yes, how do I use it? In .Net 4.0, it resides in System.Threading, but when I select .Net 3.5 as the target in Visual Studio 2010, I don't get access to classes like Parallel and the Parallel loops. ...

Overflow exception while performing parallel factorization using the .NET Task Parallel Library (TPL)

Hello, I'm trying to write a not so smart factorization program and trying to do it in parallel using TPL. However, after about 15 minutes of running on a core 2 duo machine, I am getting an aggregate exception with an overflow exception inside it. All the entries in the stack trace are part of the .NET framework, the overflow does not c...

Parallel Task Library WaitAny Design

I've just begun to explore the PTL and have a design question. My Scenario: I have a list of URLs that each refer to an image. I want each image to be downloaded in parallel. As soon as at least one image is downloaded, I want to execute a method that does something with the downloaded image. That method should NOT be parallelized --...

Practical differences between using TPL and Async Pattern

I am looking into using either of mentioned ways of dealing with long running operations. I won't be going into details what can be accomplished using each of these, but I'd rather explain what I want to do. I have a set of HTTP-related methods, each retrieving a few pieces of information. This is all part of bigger system inside of a ...

Is there a way to use the Task Parallel Library(TPL) with SQLDataReader

I like the simplicity of the Parallel.For and Parallel.ForEach extension methods in the TPL. I was wondering if there was a way to take advantage of something similar or even with the slightly more advance Tasks. Below is a typical usage for the SqlDataReader, and I was wondering if it was possible and if so how to replace the while loo...

Any C++ libraries to run a single program on multiple PC's (i.e. "use grid computing to run my app")

I'm after a method of converting a single program to run on multiple computers on a network (think "grid computing"). I'm using MSVC 2007 and C++ (non-.NET). The program I've written is ideally suited for parallel programming (its doing analysis of scientific data), so the more computers the better. ...

Handling Exceptions in a .NET 4.0 Task Parallel Library Task

I'm working on a Web Hook in .NET 4.0 that will run a lambda asynchronously and then post the result to a given URI when it is finished. I've got that to work, but now I want the Task to handle any exceptions that are thrown, and am finding it difficult to stop them from reaching the parent. Here's part of my code: private readonly Fu...