The Task Parallel Library is part of the .NET Framework since .NET 4. It is a set of APIs that simplifies the process of adding parallelism and concurrency to applications.
The Task Parallel Library (TPL) is a set of public types and APIs in the System.Threading and and the System.Threading.Tasks namespaces in the .NET Framework 4 and up. The purpose of the TPL is to make developers more productive by simplifying the process of adding parallelism and concurrency to applications. The TPL scales the degree of concurrency dynamically to most efficiently use all the processors that are available. In addition, the TPL handles the partitioning of the work, the scheduling of threads on the ThreadPool, cancellation support, state management, and other low-level details.
When you have server-side code (i.e. some ApiController) and your functions are asynchronous - so they return Task - is it considered best practice that any time you await functions that you call ConfigureAwait(false)?
I had read that it…
Are there good rule(s) for when to use Task.Delay versus Thread.Sleep?
Specifically, is there a minimum value to provide for one to be effective/efficient over the other?
Lastly, since Task.Delay causes context-switching on a async/await state…
In the code below, due to the interface, the class LazyBar must return a task from its method (and for argument's sake can't be changed). If LazyBars implementation is unusual in that it happens to run quickly and synchronously - what is the best…
I want to wait for a Task to complete with some special rules:
If it hasn't completed after X milliseconds, I want to display a message to the user.
And if it hasn't completed after Y milliseconds, I want to automatically request…
I'm using an API client that is completely asynchrounous, that is, each operation either returns Task or Task, e.g:
static async Task DoSomething(int siteId, int postId, IBlogClient client)
{
await client.DeletePost(siteId, postId); // call…
What is the difference between Task.WaitAll() and Task.WhenAll() from the Async CTP?
Can you provide some sample code to illustrate the different use cases?
I have an async method which returns no data:
public async Task MyAsyncMethod()
{
// do some stuff async, don't return any data
}
I'm calling this from another method which returns some data:
public string GetStringData()
{
MyAsyncMethod();…
I've got an interface which declares
Task DoSomethingAsync();
I'm using MoqFramework for my tests:
[TestMethod()]
public async Task MyAsyncTest()
{
Mock mock = new Mock();
mock.Setup(arg =>…
In C# 4.0, we have Task in the System.Threading.Tasks namespace. What is the true difference between Thread and Task. I did some sample program(help taken from MSDN) for my own sake of learning with
Parallel.Invoke
Parallel.For
Parallel.ForEach…
I have 3 tasks:
private async Task FeedCat() {}
private async Task SellHouse() {}
private async Task BuyCar() {}
They all need to run before my code can continue and I need the results from each as well. None of the results have…
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 I read. I've read and understand the basic principles…
Preface: I'm looking for an explanation, not just a solution. I already know the solution.
Despite having spent several days studying MSDN articles about the Task-based Asynchronous Pattern (TAP), async and await, I'm still a bit confused about some…
Using the async CTP from Microsoft for .NET,
is it possible to catch an exception thrown by an async method in the calling method?
public async void Foo()
{
var x = await DoSomethingAsync();
/* Handle the result, but sometimes an exception…
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 a foreach loop?
Parallel.ForEach(items,…