Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [task-parallel-library]

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
49 views

Sending device data of 10k items with Parallel.ForEach

I have a deviceList of more than 10k items and want to send data by calling another method. I tried to use Parallel.Foreach but I'm not sure is this the correct ...
1
vote
1answer
50 views

Parallel FTP client

I was given the task to download files for a FTP server. The download should be fairly fast. 15 parallel connections can be used. I have used FluentFTP as the ...
0
votes
0answers
53 views

Asynchronous wrapper for database connection

I'm using a database that has a library for access to it. Connection is done synchronously, it's blocking and I do not have a way to abort it. To connect, I have to write: ...
1
vote
1answer
92 views

Receiving and sending notifications from database

I'm not much familiar with Task Api programming in C#. Can anyone review my following code? The following is a ElapsedEventHandler of a ...
1
vote
0answers
44 views

Using up to 15 connections to synchronize files from a FTP server with local files

Task: Create a service which will synchronize files on FTP server with files on local drive. FTP server allows up to 15 concurent connections Synchronize the files as fast as possible Files on FTP ...
2
votes
0answers
64 views

Repeating a task that may fail (in parallel)

Almost like this question here, I'm playing with some methods that may fail, but in my case, the method failing is not a exceptional case; it just means I need to try running it again. The method I'm ...
2
votes
0answers
48 views

Task based GameObject recorder for networked game

I've recently been dipping my toes in to async code so I'm not 100% sure if there's a better way to do this, or if I'm going to run into problems down the road. I plan on using the following class in ...
1
vote
1answer
109 views

Concurrent usage of resources

Please take a look at the following code. This is my attempt at understanding concurrent applications. ...
5
votes
2answers
492 views

ForEachAsync extension method (a way to run an async operation on each item of a sequence in parallel)

In a recent project I worked on we faced some issues due to an excess of parallelization (thousands of threads were created and the overall result was a degradation of performance and several spikes ...
1
vote
1answer
47 views

Dispatch multiple publishers to single handler with result

This code defines a MessageBus used to handle messages from many producers to a single consumer. The bus allows multiple publishers to send messages asynchronously ...
4
votes
1answer
77 views

Async/Await Computation Expression

When writing asynchronous code in F#, one often needs to call methods in the .NET BCL that return Task or Task<T> rather ...
3
votes
0answers
44 views

Coordination function

This function started very clean but I had to add requirements: Added a Stopwatch to only update the caller periodically. I guess that responsibility could be ...
1
vote
1answer
753 views

Creating membership list with Parallel.ForEach [closed]

I had a foreach loop which used to loop Membership users and create list of a custom class. Following was the for loop: ...
3
votes
1answer
2k views

Simple server using async and HttpListener

I have a program that controls a custom machine. I wanted to add some simple HTTP comms so I could control it from the network or other programs. My server class is: ...
2
votes
3answers
479 views

Writing to file using TPL with ConcurrentQueue

Here is a sample code to explain the approach I am going for. ...
10
votes
0answers
276 views

Testing a list of proxies for validity concurrently

I have a class that tests a list of proxies for validity concurrently, which I have created in 2 different ways, one utilizing Parallel.ForEach and the other using a TPL Dataflow ActionBlock. I am ...
3
votes
2answers
88 views

parallel bing maps searching

Please assist and review the following task. There are many geographic data to be found using the Bing Map server. It is necessary to collect data, parse bing response and store it in one of two ...
3
votes
2answers
2k views

Running parallel tasks until they're done

The General Idea I wish to simulate something which works like Java's ThreadExecutor, but as a first step, I would like to run a fixed number of identical tasks in ...
5
votes
1answer
1k views

Process List asynchronously with SemaphoreSlim for throttling extension method

I've got some methods that follow a similar pattern, and wanted to abstract some of the logic away into an extension method. Specifically, I am processing lists of objects with the TPL, and throttling ...
1
vote
2answers
94 views

Parsing NuGet packages.config with Parallel.ForEach

Below is a file parser for old style nuget package configuration files. The Parallel.ForEach is probably overkill; in most cases its fast enough without. However, ...
4
votes
1answer
359 views

PauseOrCancelTokenSource

I added this implementation of PauseToken and PauseTokenSource to my project from this MSDN blog post: Cooperatively pausing async methods Since I will usually be passing in both a PauseToken and a ...
1
vote
2answers
152 views

Task Execution with Cancel Logic

In my assignment I am executing a long running NodeJs script from C# using EdgeJs. Since the script may take a long time to execute, I also want to provide user an option to Cancel the script ...
1
vote
0answers
120 views

F# Operation Framework (Railway-Oriented Programming + Task/Async/Lazy)

I recently published the initial version of what is effectively my first open-source software package, a Railway-Oriented Programming Framework for F# that encapsulates Tasks, Async Workflows, and ...
5
votes
1answer
145 views

Verifying that tasks are really async with AsyncDetector

Running tasks asynchronously can sometimes by tricky and no matter how careful I am, I sometimes forget some crucial part and my tasks run synchronously. I don't usually notice that until it's too ...
1
vote
0answers
5k views

Very simple task scheduler (Task based, not Timer based)

My app has several periodic tasks. So I created this very simple generic task scheduler (got sick of copy-pasting code, which is based on Timers). It is very very basic and simple, can you find ...
2
votes
2answers
1k views

C# Extending the DispatcherTimer - Intermission timer

I'm working on a WPF project where a timer with Pause/Resume functionality is required. The standard Windows.Threading.DispatcherTimer doesn't offer that, so I ...
1
vote
1answer
687 views

Async time logging in multithread application

I have a simple producer-consumer multhithread application, I am trying to measure a few points in both threads for benchmarking. What I came up with is the TPL dataflow library of .Net, and I have ...
2
votes
1answer
424 views

TPL Task tracker which keeps track of tasks

This class keeps track of tasks which are added and tries to remove them after certain delay. I tried doing it with CustomTaskScheduler but didn't get much in return. Here is my related question on ...
3
votes
1answer
459 views

Independently constraining task parallelism at different levels of a nested loop

I would like to performance test a REST API using C#. The API offers a list of endpoints, and each endpoint accepts page and size...
-1
votes
1answer
208 views

Partition TPL Tasks in ASP.net 4.0 for WCF Service

Want to know if using partition code like this is ok to do to partition tasks in ASP.NET 4.0 inside of a WCF service. My goal with this code is to try to do non-blocking calls without spinning up too ...
5
votes
1answer
335 views

Splitting a UTF-8 string into equal-sized byte-arrays for parallel processing

Based upon a question from Stack Overflow, I wanted to expand on the answer I wrote and define a solution that would support ordering the strings (after processing). So this starts off with a basic <...
4
votes
2answers
513 views

Wait for a static value to appear

In my program I need to monitor the state of a static string value that can be changed from different threads in different parts of the system. I came up with the following simple function that, once ...
1
vote
1answer
616 views

C# Multiple ASYNC requests single response (Promise like)

I'm no too good with async processes in C#. I need to implement method, that can be called multiple times by async requests, but request data and serve response once. I've created this method, ...
6
votes
1answer
151 views

Processing input in background while user is typing

Use case A GUI with 2 controls: An input control for text (a DNA sequence) that should be analyzed A result control that displays the analyzing result of the entered text The analysis takes 2-3 ...
3
votes
2answers
531 views

Process dependent results of Producer/Consumer queue with explicit locking

I have seen many examples which the results of a Producer/Consumer queue implemented using BlockingCollection<T> are independent, e.g. each result can be ...
3
votes
1answer
2k views

Wait for file method

I've been having problems with a client where the server would move a file on the server, the client would then try and access that file but get a ...
1
vote
0answers
37 views

Cancelling long running operation in MVC4

I have been wondering if the way I have implemented cancellation of a long-running import operation is correct. My questions are: Did I handle cancellation correctly? Is it ok to pass the ...
5
votes
1answer
108 views

Working with threads - shared access and graceful cancellation

I've created this program to show how to stop threads in a controlled manner. Important points in the program: Starting and waiting for threads Exception handling Stopping threads in a controlled ...
1
vote
1answer
750 views

Simple TCP server using TPL

I have a working C# code of a TCP server that runs inside a windows service. It accepts incoming connections and starts sending/receiving data based on some complex rules. The top-level class for ...
3
votes
1answer
2k 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
1k 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 ...
5
votes
1answer
2k 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
121 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 ...
-1
votes
1answer
194 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
77 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
153 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
4k 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
2k 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
991 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. ...
5
votes
0answers
2k 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 ...