task-parallel-library Questions

2

Solved

I encountered a simple problem when trying to test TPL. I would like to get numbers (from 1 to 1000) for example in the console window. This is the code that I have: class Program { static void Ma...
Remount asked 9/3, 2013 at 17:17

2

Solved

I've got a caching class that uses cold (unstarted) tasks to avoid running the expensive thing multiple times. public class AsyncConcurrentDictionary<TKey, TValue> : System.Collections.Concu...

3

Solved

For simplicity let's imagine we have a method that should return an object while doing some heavy operation. There're two ways to implement: public Task<object> Foo() { return Task.Ru...
Upanishad asked 25/3, 2016 at 7:44

3

Solved

I would like to fetch data from multiple locations from Firebase Realtime Database like described here and here by Frank van Puffelen and I can't find any equivalent to Promise.all in c#. What woul...
Effable asked 2/2, 2019 at 18:0

4

I'd like to write a bunch of methods querying the Oracle Database in the async/await way. Since ODP.NET seems to support neither awaitable *Async methods nor Begin/EndOperationName pairs, what opti...
Dovev asked 3/1, 2013 at 10:4

12

Solved

AFAIK, all it knows is that at some point, its SetResult or SetException method is being called to complete the Task<T> exposed through its Task property. In other words, it acts as the produ...

2

Solved

I want to have a EventWaitHandle-like Task where I await on it on one end, and then just set it to completed on the other end. TaskCompletionSource is almost what I want, but it requires me to pass...
Farnesol asked 8/7, 2015 at 8:39

12

Solved

What would be the async (awaitable) equivalent of AutoResetEvent? If in the classic thread synchronization we would use something like this: AutoResetEvent signal = new AutoResetEvent(false); ...
Unsuccess asked 18/9, 2015 at 14:28

5

Solved

I've discovered that TaskCompletionSource.SetResult(); invokes the code awaiting the task before returning. In my case that result in a deadlock. This is a simplified version that is started in an...

5

Solved

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 wi...
Yablon asked 2/9, 2014 at 21:35

4

Solved

Here is the code I have but I don't understand what SemaphoreSlim is doing. async Task WorkerMainAsync() { SemaphoreSlim ss = new SemaphoreSlim(10); List<Task> trackedTasks = new List<Ta...
Confine asked 18/11, 2013 at 20:2

2

Solved

The ASP.NET Core 2.0 documentation defines the IHostedService interface as follows: StartAsync(CancellationToken) - Called after the server has started and IApplicationLifetime.ApplicationStarted ...
Ellieellinger asked 30/4, 2018 at 15:16

13

Solved

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 recogni...
Pula asked 7/12, 2012 at 11:34

4

Solved

I am looking to get the method/action name from a task in C#. Specifically I am implementing a custom task scheduler, and would like to generate statistics on the duration a task runs, which I will...
Olimpiaolin asked 23/8, 2012 at 5:38

4

Solved

Currenly using the following code to wait for a collection of tasks to complete. However, I now have a situation where I want to be able to cancel/abort the WhenAll call, via a cancellation token p...
Intercross asked 1/12, 2014 at 22:6

2

Why Parallel.ForEach loop exits with OperationCancelledException, while using GetConsumableEnumerable? //outside the function static BlockingCollection<double> _collection = new BlockingColle...

7

Solved

The MSDN documentation for Task.ContinueWith has only one code example where one task (dTask) runs in the background, followed by (using ContinueWith) a second task (dTask2). The essence of the sam...
Professoriate asked 21/12, 2013 at 17:18

5

Solved

Using Dataflow CTP (in the TPL) Is there a way to call BatchBlock.TriggerBatch automatically if the number of currently queued or postponed items is less than the BatchSize, after a timeout? And be...
Windtight asked 23/2, 2012 at 19:1

4

Solved

Lets say that i have a couple of tasks: void Sample(IEnumerable<int> someInts) { var taskList = someInts.Select(x => DownloadSomeString(x)); } async Task<string> DownloadSomeStrin...
Malmsey asked 30/5, 2016 at 15:2

10

Solved

When a user loads a page, it makes one or more ajax requests, which hit ASP.NET Web API 2 controllers. If the user navigates to another page, before these ajax requests complete, the requests are c...

2

Solved

Hopefully a fairly simple one here. I have a collection of objects, each of which has an async method that I want to call and collect values from. I'd like them to run in parallel. What I'd like to...
Cutlet asked 10/11, 2014 at 8:45

5

Solved

I start a task, that starts other tasks and so forth. Given that tree, if any task fails the result of the whole operation is useless. I'm considering using cancellation tokens. To my surprise, the...
Accessible asked 16/6, 2015 at 18:23

11

Solved

I need to run multiple async tasks in a console application, and wait for them all to complete before further processing. There's many articles out there, but I seem to get more confused the more ...
Pandean asked 29/7, 2014 at 6:34

5

Consider Using async without await. think that maybe you misunderstand what async does. The warning is exactly right: if you mark your method async but don't use await anywhere, then your method w...
Corncrib asked 23/7, 2013 at 9:7

3

Solved

I am porting some code to Parallel.ForEach and got an error with a continue I have in the code. Is there something equivalent I can use in a Parallel.ForEach functionally equivalent to continue in ...

© 2022 - 2025 — McMap. All rights reserved.