Skip to main content
3 votes
1 answer
2k views

I have a batch block in tpl dataflow and have several target blocks linked to the batch block. However, the number of target blocks changes dynamically and thus the size of the batches. Problem is ...
28 votes
14 answers
26k views

I'm going to use lots of tasks running on my application. Each bunch of tasks is running for some reason. I would like to name these tasks so when I watch the Parallel Tasks window, I could recognize ...
0 votes
1 answer
123 views

I have the following C# code : var rand = new Random(1); var range = Enumerable.Range(1, 8); var partition = Partitioner.Create(range, EnumerablePartitionerOptions.NoBuffering); foreach (var x in ...
17 votes
5 answers
6k views

So, task.Wait() can be transformed to await task. The semantics are different, of course, but this is roughly how I would go about transforming a blocking code with Waits to an asynchronous code with ...
3 votes
6 answers
2k views

Let's say I have a list of Tasks, and I want to run them in parallel. But I don't need all of them to finish to continue, I can move on with just one. The following code waits for all the tasks to ...
8 votes
3 answers
13k views

I have the following lines in my code: var taskA = Task.Factory.StartNew(WorkA); var taskB = Task.Factory.StartNew(WorkB); var allTasks = new[] { taskA, taskB }; Task.Factory....
5 votes
2 answers
25k views

We would like to optionally control the number of "threads" on our parallel loops to avoid overwhelming a web service (for example). Is it possible to specify a custom MaxDegreeOfParallelism on a ...
8 votes
1 answer
2k views

I saw Jon Skeet give a talk a year or so ago where he showed a snippet of C# 5 that would take a list of Tasks and return them in the order they completed. It made use of async/await and WhenAny and ...
6 votes
3 answers
11k views

I'm having a hard time finding a task scheduler on which I can schedule prioritised tasks but can also handle "wrapped" tasks. It is something like what Task.Run tries to solve, but you ...
1 vote
2 answers
175 views

I have some code in a dll project with the target as .Net 8. In my code there is an async method called EmailNonError which is being called with the following code. When this code executes, the email ...
0 votes
1 answer
59 views

The first exception does not block the execution: public static async Task Main() { await Task.WhenAny( Task.WhenAll( Task.Run(() => throw new Exception(&...
18 votes
8 answers
18k views

How can I unit test component that has an await Task.Delay without really having to wait for it. For example, public void Retry() { // doSomething(); if(fail) await Task.Delay(5000); ...
16 votes
6 answers
4k views

Some of us prefer to code in an exception-light style. However, if you wait for a Task Parallel Library task, and the task threw an exception, it will throw an exception on the calling thread as well. ...
13 votes
3 answers
9k views

I'm using PagedList in my Views, but my scaffolded Controller is generated with this kind of default Index Action: public async Task<ActionResult> Index() { return View(await db.Claimants....
51 votes
5 answers
42k views

I am trying to set the apartment state on a task but see no option in doing this. Is there a way to do this using a Task? for (int i = 0; i < zom.Count; i++) { Task t = Task.Factory.StartNew(...

15 30 50 per page
1
2 3 4 5
420