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.
1
vote
1answer
19 views
Creating a concurrent/parallel ForEachAsync that can fail immediately or wait until enumeration is complete
I needed an asynchronous parallel ForEach mechanism so I could enumerate an enumerable by N degrees of concurrency and process an action for each item. Searching ...
2
votes
1answer
49 views
Logging requests on a separate thread
I have an ASP.NET MVC 5 application that needs to log to the database every request for a specific controller action and every link click that happens on the view of that action. Since the user ...
4
votes
1answer
90 views
Consuming chunks from ConcurrentQueue
I need to implement a queue of requests which can be populated from multiple threads. When this queue becomes larger than 1000 completed requests, these requests should be stored into a database.
<...
1
vote
0answers
25 views
Producer Consumer With Multiple Dependents
I put together a ProducerConsumer class that wraps the C#'s BlockingCollection class with some bells and whistles (producers can have multiple consumers, consumers can have lambdas, built in parallel ...
0
votes
1answer
47 views
Web crawler that uses Task Parallel Library
This is the first time using the Task Parallel Library and it seems to be performing much slower than I was expecting. The application is simply a web crawler that returns all URLs for a given URL.
...
3
votes
0answers
45 views
Making recurring requests to a web service using Task.Run
I am practicing with using Tasks and I put something together but am unsure if I used it properly. I read through Stephen Cleary's blog and it seems that it is okay but at the same time I do some ...
2
votes
1answer
79 views
Performance of an OLX crawler
I'm learning concurrency and asynchronous programming in C#. For a better grasp on the matter I'm trying to create an OLX Crawler. My issue here is the performance: It takes roughly 159 minutes to ...
3
votes
1answer
48 views
Run multiple prerequisite methods in parallel before continuing
I have an application in which I have multiple slow running prerequisite methods I need to call in order to have the data I need to continue.
To try to speed this up I am doing this:
...
2
votes
1answer
131 views
Using BlockingCollection with Parallel.ForEach
I have a process that does a bunch of document processing. One of the tasks being performed is OCR, which is the slowest part of the process, so I decided to run that in another thread.
I decided ...
1
vote
2answers
241 views
Parallel process interest in C#
In web api controller:
I am a newer in parallel and Async&Task programming. Need someone help me code review.
...
4
votes
0answers
247 views
Socket application using TPL
This is an application I wrote that allows multiple TCP clients to share a single TCP connection to a remote server (hosted project, and a demo). Traffic generated by the server is forwarded to all ...
2
votes
1answer
129 views
WebAPI Handling fire and forget exceptions
This is a fire and forget task from within an existing WebAPI service. The code below simply sends a log event (might be that a client has connected to the service to perform some task) to another ...
3
votes
3answers
382 views
Performing parallel processing on a file
I have some code that reads a file and then does some parallel processing of the data. There are millions of lines in the file and this section of the code is the bottleneck in my program. Any ...
0
votes
1answer
57 views
Tree processing for series and parallel execution
I have a tree processing application where some of the nodes are "executed" in parallel and some in series. I managed to do this but I feel that the solution looks a bit "hacked up" and can be ...
3
votes
2answers
62 views
Going to the thread pool and back using custom awaiters
I've figured out a way to switch threads in the middle of a method. The benefit of that seems super obvious to me: that's what everyone wants to do anyway, and splitting up methods, using callbacks, ...
2
votes
1answer
842 views
Parallel Task Queue that runs in sequence
I'm in need of a solution that runs constantly incoming requests in a per-resource sequence, but parallel in general.
The use-case:
Many clients connect to a server and start issuing work. The work ...
0
votes
1answer
2k views
Starting a fire and forget async method
Sonar/FxCop are telling us that we shouldn't use void async methods. That's ok.
This is the current implementation:
...
1
vote
0answers
311 views
Are there pitfalls to this solution to read messages from a queue in parallel?
I've posted a question on stackoverflow: How can I consequently read messages from a queue in parallel? I would like my own answer to be reviewed.
Situation
We have one message queue. We would like ...
7
votes
3answers
125 views
Downloading files from a Mozilla file server via FTP
All classes on GitHub repo
This is the code for downloading files from a FTP-server running Mozilla Fileserver.
FtpItem is the interface for the two classes ...
3
votes
1answer
111 views
Suggestion for a lot of chained Task [closed]
I have a lot of Task continuation that depend on .Result of previous Task -> for example: I ...
10
votes
3answers
507 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 ...
5
votes
1answer
92 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 ...
10
votes
3answers
456 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 ...
39
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 ...
2
votes
0answers
55 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
82 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
75 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
141 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
148 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 ...
3
votes
1answer
103 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
159 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
785 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 ...
6
votes
1answer
2k 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
3k 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
523 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
801 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 (it'...
5
votes
2answers
107 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
1k views
Measure a given method's execution time - follow-up
A 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
242 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
249 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
475 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
111 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
6k 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
194 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
2k 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 ...
4
votes
1answer
2k 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
4k 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
2k 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 ...
2
votes
1answer
1k views
11
votes
3answers
933 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 ...