VB.NET || How To Create Multiple Tasks With Maximum Concurrency Using VB.NET

Print Friendly, PDF & Email

The following is a module with functions which demonstrates how to create multiple tasks with maximum concurrency using VB.NET.

The examples demonstrated on this page uses System.Threading.Tasks.Task to start and run tasks. They also use System.Threading.SemaphoreSlim to limit the number of tasks that can run concurrently.

The examples on this page demonstrates how to start and run multiple tasks with a maximum concurrency. It also demonstrated how to start and run multiple tasks with a return value.


1. Task – Maximum Concurrency

The example below demonstrates how to start and run multiple tasks with a maximum concurrency. For example purposes, the tasks do not return a value.

The functions shown in the example below are called asynchronously, but they can also be called synchronously.


2. Task – Maximum Concurrency – Return Value

The example below demonstrates how to start and run multiple tasks with a maximum concurrency. In this example, a value is returned and retrieved from the tasks

The functions shown in the example below are called asynchronously, but they can also be called synchronously.


3. More Examples

Below is a full example of the process demonstrated on this page!

QUICK NOTES:
The highlighted lines are sections of interest to look out for.

The code is heavily commented, so no further insight is necessary. If you have any questions, feel free to leave a comment below.

Leave a Reply