Linked Questions

281 votes
4 answers
148k views

Parallel.ForEach vs Task.Factory.StartNew

What is the difference between the below code snippets? Won't both be using threadpool threads? For instance if I want to call a function for each item in a collection, Parallel.ForEach<Item>(...
stackoverflowuser's user avatar
13 votes
5 answers
6k views

Limiting the amount of concurrent tasks in .NET 4.5

Observer the following function: public Task RunInOrderAsync<TTaskSeed>(IEnumerable<TTaskSeed> taskSeedGenerator, CreateTaskDelegate<TTaskSeed> createTask, ...
mark's user avatar
  • 60.4k
5 votes
4 answers
14k views

Can I limit the amount of System.Threading.Tasks.Task objects that run simultaneously?

I am using Task classes to do multi-threaded computation. For example: List<Task> taskList = new List<Task>(); for(int i=0;i<10;i++){ var task = new Task(() => ...
Andrey Rubshtein's user avatar
4 votes
2 answers
2k views

How to make concurrent requests without creating multiple threads?

Can someone please show how to make concurrent requests without creating multiple threads? E.g., I want a program that makes 100 web requests and I don't want more than 8 concurrent requests at any ...
morpheus's user avatar
  • 19.5k
2 votes
1 answer
3k views

What are the main differences between using Parallel.ForEach & Task.Factory.StartNew

i am working on an asp.net mvc-4 web application.. but i am not sure what are the differences between using these 2 approaches for iteration over a list and initiate WebClient() calls :- Approach-1 ...
John John's user avatar
3 votes
1 answer
3k views

Limit the number of Tasks in Task.Factory.Start by second

I've seen a number of posts about limiting the number of tasks at a time (System.Threading.Tasks - Limit the number of concurrent Tasks is a good one). However, I need to limit the number of tasks ...
Prescott's user avatar
  • 7,392
3 votes
3 answers
785 views

F# Async File Copy

To copy a file asynchronously, will something like this work? let filecopyasync (source, target) = let task = Task.Run((fun () ->File.Copy(source, target, true))) // do other stuff ...
user1443098's user avatar
  • 7,057
0 votes
2 answers
510 views

Custom task framework

I would like to know if there is an existent framework which can manage some "tasks". I'm aware of Task Parallelism, but (correct me if I'm wrong) I don't think it fits my needs (mostly because it ...
J4N's user avatar
  • 20k
1 vote
3 answers
2k views

How to queue some amount of work so they execute in sequence

I have a queue of tasks or work items that needs to be executed in sequence, in the background. These tasks will be of the "fire and forget" type, meaning that once they are started, I do not really ...
Vincent Hubert's user avatar
1 vote
1 answer
795 views

Controlling the number of parallel tasks running simultaneously

I have a Windows service application that has a number of different jobs that need to be done in parallel and are spawned on three different schedules. However I want to make sure that at no point of ...
ConfusedMan's user avatar
0 votes
2 answers
622 views

Limit total concurrent tasks running [duplicate]

I have a method Create which is executed whenever a new message is seen on the service bus message queue (https://azure.microsoft.com/en-us/services/service-bus/). I am trying to limit the total ...
Jeppe's user avatar
  • 1,484
0 votes
1 answer
609 views

Synchronization of remote files download

Preamble: it's a self-assigned and pure syntetic task to learn (and remember what I already knew) C# threads and synchronization and data structures. The story: Let's say I have a dictionary <...
zerkms's user avatar
  • 253k
4 votes
2 answers
180 views

Retrieve information from a REST service asynchronously while throttling the number of requests

I have a program that needs to get some data from an Atom feed. I tried two approaches and neither of them worked well. I've used WebClient to synchronously download all the posts I need, but as ...
TEst16's user avatar
  • 407
0 votes
2 answers
539 views

Need help in deciding when is it good idea to limit the 'number of thread pool threads .net app consumes'?

I have HTTP client which basically invokes multiple web requests against HTTP server. And I execute each HTTP request in a thread pool thread (synchronous call), and by default uses 30 TCP (using ...
NNP's user avatar
  • 3,411
0 votes
2 answers
120 views

Creating worker "tasks" to dealing with limited resources

I am looking for a mechanism already in c# that will allow me to do something like this: 10 images need to be decoded there is only enough memory to decode 2 start decoding 2, put the rest in a job ...
user1660943's user avatar

15 30 50 per page