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.
4
votes
1answer
94 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
50 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:
class ...
4
votes
2answers
178 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 task, until it is been Disposeed, a ...
4
votes
1answer
91 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 processing is happening (either for the ...
5
votes
1answer
116 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
42 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 ...
9
votes
1answer
257 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
269 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 techniques.
So I created a new WinForms project, and implemented a ...
3
votes
1answer
85 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
120 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
72 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
243 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
159 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
54 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 here. Here's a simplified version of ...
2
votes
1answer
90 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 to slow down significantly which ...
2
votes
1answer
121 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
208 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 Task<bool>.
Obviously this isn't supported, so ...
1
vote
1answer
100 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
6k 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
75 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.
public static Task<R> ContinueWhenBoth<T1, T2, ...
0
votes
1answer
174 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
508 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
191 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
3k 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
442 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?
/// <summary>
/// Handles ...
2
votes
1answer
2k views
Use and Understanding of async/await in .NET 4.5 +
All, please take the following example code
CancellationTokenSource cancelSource;
// Mark the event handler with async so you can use await in it.
private async void StartButton_Click(object ...
1
vote
1answer
788 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
293 views
Please review my 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
3k views
Correct approach to wait for multiple async methods to complete
I have an IWorkflow interface defined as follows:
public interface IWorkflow
{
Task ConfigureAsync();
Task StartAsync();
Task StopAsync();
}
And I have an Engine class:
public sealed ...