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

learn more… | top users | synonyms

11
votes
3answers
629 views

WhenAll for .NET 3.5

I am trying to write a version of Task.WhenAll for .NET 3.5 using the "Task Parallel Library for .NET 3.5". This is what I came up with. Is there a better way of ...
8
votes
1answer
115 views

Asynchronous retry method

I've written an asynchronous retry method as an answer for this question. I'd like to get your opinion of the implementation and whether there are better ways to implement this. You could also ...
2
votes
1answer
47 views

Cross Thread Access to Object in ViewModel

This is a fairly straight forward question. I have a C# WPF MVVM application that call a C++ DLL to do some compilation/crunching. To update the UI C# application for progress updates I am using ...
4
votes
1answer
106 views

Simple parallel foreach loop code correctness

I have both the regular for each loop and its equivalent paralleled version. The loop simply iterates through a collection, looking for the rate key in a local db ...
5
votes
1answer
414 views

Writing highly asynchronous code

I am writing a new web service that will be performing a lot of large data load operations. To do so I am moving the data to a temporary table then merging the data in to the live data via a stored ...
3
votes
1answer
96 views

TaskScheduler that uses a dedicated thread

I'm trying to implement a TaskScheduler that runs all tasks in the order they are submitted, on a single dedicated thread. Here's my implementation, using a BlockingCollection: ...
5
votes
2answers
2k views

A TaskScheduler that always run tasks in a specific thread

The following is an TaskScheduler that always run tasks in a thread it maintains. When created, a name of the thread was specified. Once you schedule the first ...
4
votes
1answer
493 views

Async Queue Processing

I have a Queue that needs to try to process when anything updates in it (add, remove or update). However, I don't want any of the callers to wait while the ...
5
votes
2answers
510 views

Listen to multiple RabbitMQ queue by task and process the message

Single app which listen to multiple RabbitMQ queue and process the message. This is working fine but not sure this implementation is right one or I am missing something. Implementation is inspired ...
2
votes
1answer
70 views

Run the most recently requested action after finishing current, skip middle tasks

The goals for the code below are in the class summary below. Can anyone see that the code fails at any of those goals? I'm unsure how to thoroughly test it. Is there a way to keep the Queue method ...
11
votes
1answer
2k views

Websockets client code and making it production-ready

The following code is helpful to anyone who uses websockets in general... and is probably good template for anyone getting started in this area. I'd like to flesh this out into something that is more ...
10
votes
2answers
822 views

BackgroundWorker vs TPL ProgressBar Exercise

I wanted to fiddle around with the BackgroundWorker and Task classes, to see how I would implement a given task with these two ...
3
votes
1answer
131 views

Run control tasks asynchronously using TPL

One of my classes regularly triggers one of two asynchronous operations: a "turn on" and a "turn off" that each take about a second. I'm using this method below to make sure that they don't run ...
5
votes
1answer
226 views

Non locking UI code in WP8

I've recently started to delve into the world of windows phone 8 dev, and as a learning experience I've decided to make a stopwatch application. Now, given I've been a web guy most of my career, I've ...
2
votes
0answers
122 views

Easy way to handle AcceptMessageSessionAsync and ReceiveAsync - Windows Server ServiceBus

Attempting to jump into the Windows Server ServiceBus 1.1 code-base along with adopting the new TPL async methods. But I could not find an easy way to just spin up N number of handlers for message ...
8
votes
1answer
381 views

Implementing a cancellable “infinite” loop

I'm making a Windows service that watches a directory for new files to process them. I hit a race condition between the file copying going on and me trying to process it. Going by a SO answer I wrote ...
2
votes
1answer
322 views

Generic Task Progress Dialog

I'm attempting to write a Progress Dialog that I can instantiate, show and then pass a task to complete to. I'm pretty new to Task Based Patterns, so please bear with me. Ideally my goal is to be ...
5
votes
2answers
76 views

Is Concurrent Collection Needed Here?

I'm playing around with switching some code to using Parallel.ForEach and I have a question about whether I need to be concerned about the effects of concurrency ...
2
votes
1answer
96 views

parallel.For function

I am trying to add parallelism. The following function works. For testing purposes, calculating chunckLength is fine. However, when I allocate more cores, it seems ...
2
votes
1answer
163 views

Barnes-Hut implementation of the N-Body problem translated from F# to C#

I am after a peer review of a C# implementation of the Barnes-Hut algorithm which I have translated from F#. The F# version is the base for comparison, therefore the C# version is suppose to reflect ...
3
votes
1answer
559 views

Filtering a collection by an async result

I'm trying to do something like this: var loudDogs = dogs.Where(async d => await d.IsYappyAsync); The "IsYappyAsync" property would return a ...
1
vote
1answer
114 views

Converting a method to async

I have a method that calls a "bridge" for "TraderMarketInfo". When info is received, it checks if info IsSet and raises an event. I wan to make this method async. C# .NET4.0 VS2012 Original method: ...
5
votes
2answers
9k views

C# Console Chat Server - Async/Await, TcpClient/TcpListener, NetworkStream (async)

Just looking for feedback on correctness of my understanding of async/await. Curious about the Task.Run inside of the StartReceive() method. Resharper (or maybe just the compiler) warns against ...
1
vote
2answers
81 views

TaskFactory.CompleteWhenBoth

I'm trying to construct something which would work a bit like Zip for two tasks, but I'm a bit worried about race conditions in this code. ...
0
votes
1answer
201 views

Using Barrier to Implement Go's Wait Group

I have implemented a WaitGroup class to simulate WaitGroup in Go lang. Then I've found that I can use Barrier in a different manner, to achieve the same thing. My WaitGroup has some additional ...
3
votes
2answers
975 views

Tasks: exceptions and cancelation

I need to do a long running task. I've done this by executing a Task while there's a loading box on the UI. When an exception is thrown, I want to stop the task and show a msgbox to the user. If ...
3
votes
1answer
281 views

Need guidance using Tasks

I am doing multithreading using TPL Tasks first time. This is what i have done so far and I want to do it the right way. I will really appreciate if you could honor me with your expert advice. I am ...
4
votes
1answer
4k views

C# 5 Async Await .Task.Factory.StartNew cancellation

I have the async code that implements cancellation token. It's working but Im not pretty sure if this is the right way to do it so I just want feedback about it. Here is the actual code: ...
7
votes
2answers
589 views

Task.Finally extension, good, bad, or ugly?

I wrote this, and it has helped to avoid the 'Some exception weren't handled' problem. Is there something glaringly wrong with this that I might have missed? ...
2
votes
1answer
3k views

Use and Understanding of async/await in .NET 4.5 +

All, please take the following example code ...
1
vote
1answer
1k views

TPL Thread Leak and Memory Leak

I'm trying to track down what I suppose to be memory/thread leak in one of my programs. My program uses a function to upload a file to a Windows Azure Storage Blob. In order to make this function ...
4
votes
2answers
383 views

UNC path exists monitor

This is my first attempt at trying to write a "monitor" class to determine if a UNC path is available. I need the monitor to not block the main thread and to also event when the UNC is toggled UP/DOWN ...
2
votes
1answer
5k views

Correct approach to wait for multiple async methods to complete

I have an IWorkflow interface defined as follows: ...