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.
151 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
6
votes
1
answer
361
views
TimeProvider.Delay as a unit test friendly alternative to Task.Delay
.NET 8 finally introduced a time abstraction that can be used to fake advance a clock while testing certain components.
https://learn.microsoft.com/en-us/dotnet/api/system.timeprovider?view=net-9.0
...
1
vote
1
answer
407
views
Request-response model over sockets/websockets
This is a request-response model over sockets/websockets (like HTTP) where you technically match request id to response id and return the response. In addition to that, there is timeout in case that ...
4
votes
1
answer
188
views
Implement DRY principle with IAsyncDisposable
This is a tiny class that creates backup copies of a file so these can be diff'ed to spot the changes compared to last run; used when generating code and so far has proved to be very helpful.
...
3
votes
2
answers
2k
views
Extension methods to modify an async Task's type from Task<IEnumerable<T>> to Task<List<T>>
I've written a lot of (await SomeTask).AsList(); in my project, and it's kind of annoying to keep wrapping it.
To fix this I've written a little extension method on ...
1
vote
1
answer
647
views
Make C++ Task class similiar to C#'s Task
I am enjoying making various programs with C++.
This is my first code review request. And I hope I can get some insights or might have good advice to make my code better.
I make a task class using C++...
3
votes
0
answers
8k
views
What is better - using SerialPort with or without await/async methods?
I'm having an implementation using SerialPort in C# using Visual Studio 2019. I'm using it in a Windows Application, using .NET Framework 4.7.2.
When I open and ...
2
votes
0
answers
605
views
Is there a more elegant syntax using "Task.WaitAll" for 2 tasks and timeout
I'm using the SerialPort in C# using Visual Studio 2019.
My SerialPort has 2 "pump" tasks, which are private members of my SerialPort, and are started during an Initialization method:
...
1
vote
1
answer
378
views
What is wrong with this CancellationTokenSource example
Anybody mind providing an opinion on whether or not this is a good or bad example of Task Cancellation and why. I have my own opinion and I've been told that its baseless, just trying to find out who ...
1
vote
1
answer
714
views
Execute .NET Core 3.1 background worker tasks simultaneously
I have following code:
...
3
votes
3
answers
1k
views
Throttled execution of an enumeration of Tasks
Example of use:
var users = await usernames.SelectTaskResults(GetUserDetails, 4);
where GetUserDetails(string username) is a ...
1
vote
1
answer
550
views
Render multiple SSRS reports in parallel
This service takes in a report request object that can contain multiple reports that need to be rendered. This code works but I'm not sure if I've implemented anything wrong. Note the ...
4
votes
1
answer
99
views
In-proc event dispatching through IoC container
Here is the sender and handler interfaces:
...
5
votes
1
answer
760
views
Parallel Calls to External WCF Service - ASP.NET Web Api
I have come across a situation where I feel running some code in parallel will greatly improve performance, but I am concerned about the implementation and am looking for some confirmation. Take the ...
2
votes
1
answer
626
views
A method that calls multiple async tasks with error handling, done the right way?
I've got a method, CheckForValue(), that uses named pipes to send a message to another process running locally, and then receive a message from that process, ...
1
vote
1
answer
514
views
C# extension method to do some action if a target operation takes too long time to finish
I have a potentially long running operation and I want to trigger some action if takes too long time. Also I want to reuse this logic. Operation to check:
...