반응형
If you are running .NET-based development and multiprocessor, you can improve performance by parallel processing. For For, ForEach, which is often used for iterative data processing, you can experience up to 50% improvement in performance. Here, let’s compare it through ForEach. A typical ForEach statement is shown
foreach (var item in Queue)
{
//loop code insert
}
Add using System.Threading.Tasks to the top for parallelism. Then change the ForEach statement as shown below.
Parallel.ForEach(Queue, item => { //loop code insert});
One characteristic of parallel processing is that loop code must be grouped together.
Please note, however, that you can not use it in applications where sequential processing is required.
반응형
'.Net' 카테고리의 다른 글
.NET - Error unprotecting the session cookie. (0) | 2020.12.09 |
---|---|
.NET5 - 새로운 기능 Record (0) | 2020.12.03 |
.NET - Semaphore 초기값? initialCount, maximumCount (0) | 2020.12.01 |
.NET - Thread Start with Argument or Data (0) | 2020.11.30 |
.Net - EF 'Entity type 'xxx' has composite primary key defined with data annotations. To set composite primary key, use fluent API.' (0) | 2020.11.26 |