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.
2
votes
0answers
24 views
Parallelized download of multiple images based on URL
I decided to rewrite a previous program of mine from scratch. The result is a lot better than the previous one but now that it seems like it is working I want to optimize it (hopefully it is not too ...
3
votes
0answers
22 views
Multithreaded Mandelbrot Generator Ver 3
I thought Ver 2 was fairly solid but ending up modifying all but one method for Ver 3. Performance for Generate is the same, but I was able to simplify the method ...
6
votes
3answers
380 views
Multithreaded Mandelbrot Generator Ver 2
Update: Version 3 is here.
My first version was an answer I provided to EBrown for his original post titled "Multithreaded Mandelbrot Generator". My answer had many good things in it, but I felt ...
34
votes
3answers
5k views
I'm in your .zips crackin' your passwords
As an attempt to learn multithreading better, I wrote a program to crack the password of a ZIP file. It is sort of slow, processing a three-digit password of the 95 printable ASCII characters in ...
1
vote
0answers
34 views
Safely aborting thrid-party code using TPL
I'm using some third-party libraries in my project. Once in a while the code in these libraries freaks out and produces infinite loops and other nasty things. My goal is to write a wrapper that allows ...
1
vote
2answers
66 views
Generate all available numbers for pattern, shuffle and save to multiple files
I've build simple application that allows me to generate all numbers that have desired length and start with prefix.
For example if I specify 12 as prefix and set ...
3
votes
1answer
65 views
Await state async
For speed we sometimes return response to consumer before state is saved in DB. Sometimes (Mostly for our automated consumers) this can break because the want to make actions on the saved data before ...
2
votes
0answers
56 views
Implementing TAP around WMI
I'm trying to improve my skills with the Task-based Asynchronous Pattern (TAP), by writing simple task-based wrappers around some WMI methods:
...
2
votes
1answer
94 views
Thread-safe database updates
I have the following method that will return VariantID for given VariantName ("Name" in db).
To avoid calling my db few thousand times I have dumped all records (~30) to the simple dictionary.
I'm ...
1
vote
0answers
46 views
Simple wrapper to use IEnumerable as a producer in a producer-consumer pattern
I have a relatively simple problem: I have an IEnumerable<T>, which takes considerable time to yield each term. This is then used by another piece of code, ...
2
votes
2answers
104 views
Optimized ulong prime test using 6k+/-1 in parallel threads with C#
For primality testing of 64 bit ulong, I have optimized a very fast trial-by-division test using possible factors of the form 6k+/-1. For input numbers less than ...
4
votes
1answer
169 views
Refreshing customer list periodically in the background
I have a method RefreshCustomersInternal that refreshes customer data from a server and returns a Task. Since this process is ...
4
votes
1answer
374 views
Throttle actions by number per period
I want to throttle asynchronous actions at a specific maximum rate of n actions per t period, and have pending actions wait until there is a free slot (rather than drop them). I want to receive the ...
8
votes
1answer
982 views
TPL inside Windows Service
I need to perform few tasks inside a Windows Service I am writing in parallel. I am using VS2013, .NET 4.5 and this post shows that TPL is the way to go.
I was wondering if anyone can tell me if I ...
4
votes
2answers
233 views
High udpclient CPU use
I have a bunch of different ports I want to listen on and the iterate over the available data to send to a Dataflow pipeline. In total I'm listening on 14 ports. I'm looking for any advice on how to ...
12
votes
2answers
786 views
Wait, is that variable ever assigned?
One of the inspections we wanted to implement in Rubberduck for the next release, is one that finds all unassigned variables in a VBA project.
Implementing this inspection has been ...complicated ...
5
votes
2answers
91 views
Forced Async operation in a (event like) method
I have a piece of code that I am not feeling comfortable.
I don't want to block the UI
Read operation works synchronously (reading may broke 50 ms rule)
Save operation supports async (returns ...
4
votes
2answers
508 views
Measure Method executing time - 2nd Attempt
Long time ago I've written a method that would allow me to measure the amount of time a method takes to run. I've decided to tweak this method and make use of TPL since measuring a method may take ...
5
votes
2answers
130 views
Parallelizing bitmap methods
I created a class called QuickBitmap to quickly get/set pixels in a Bitmap object. Using intertops I'm able to safely lock/unlock the bits of the ...
2
votes
1answer
137 views
Batcher using Microsoft.Tpl.Dataflow
What do you think? In particular, I'm not sure about my exception handling approach to raise errors when posting objects; but I couldn't come up with anything better.
...
5
votes
1answer
217 views
Achieving a never-ending loop of game tasks
The following is a basic implementation of a loop which is intended to launch a series of games in a loop (generic ones that can be overridden, but that have always have finite durations). The ...
3
votes
1answer
95 views
Event Subscriber with Parallelism
I am trying to exploit asynchronism for parallelism. This is my first attempt at a parallel event subscriber. In your expert opinions, is this a valid approach?
...
4
votes
2answers
3k views
Speeding up Parallel.ForEach iterating through datatable and rendering report
I am attempting to speed up the processing of 5000 rows received from the database, which I then render as a crystal report, export to a byte stream and save in a database table.
Currently I am using ...
5
votes
1answer
131 views
Server that supports two types of connections
I'm wonder if my approach is correct. I'm trying to make a WinForms server that processes data from 3 sides:
from bluettoh (InTheHand library) as source data which I need to process in server
to ...
3
votes
1answer
952 views
TPL Dataflow BatchBlock with Batch Size & Timeout
I needed BatchBlock with support for timeout (act greedy on what it received at that time) and by some search and study, this is the outcome.
What are drawbacks or ...
3
votes
1answer
1k views
Monitoring progress in Parallel.ForEach every minute
I'm using Parallel.ForEach to download 500K URLs and I want to monitor the number of URLs that have been successfully downloaded each minute.
...
2
votes
2answers
2k views
Queue with task parallel library
I am new to programming using the .Net TPL Framework and multi-threading in general. I have googled up some tutorials and articles and put together the solution below.
It is a simple multithreaded ...
4
votes
1answer
714 views
Avoid while(true) in task scheduling code
I am writing a task scheduler (that will one day grow up to be a windows service when I look into them) that should pretty much loop infinitely until I tell the program to stop. But having ...
1
vote
1answer
2k views
Creating Thread Safe or Concurrent List [closed]
Can a thread safe or concurrent list be created using the code mentioned underneath, where I wrap all the calls to the base class in a ReaderWriter lock. I can similarly implement all the public ...
2
votes
1answer
718 views
11
votes
3answers
841 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
984 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
340 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
3k 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 ...
7
votes
1answer
5k 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
734 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
12k 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 ...
7
votes
1answer
4k 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
3k 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
372 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 ...
14
votes
2answers
14k 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 ...
12
votes
2answers
5k 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
375 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
559 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
363 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
2k 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 ...
3
votes
1answer
1k 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
448 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
101 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
394 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 ...