Skip to main content

Posts

Showing posts with the label chsarp

Fixing High CPU Usage in .NET Core using Parallelism

  We will fix problem occurs due to incorrect use Parallelism in .NET Core To increase application performance sometimes we use process task or work extensively in Parallel and that may lead performance issue. When we do code, we should understand our requirement very carefully along with hardware resources those we have. We should code like that there should be less CPU usage and server should work without issues. In .NET Core, when you’re using parallelism (like Parallel.For, Task.WhenAll, or Task.Run), you might encounter performance issues if the number of concurrent threads or tasks exceeds what your system can efficiently handle. A common issue is high CPU usage or resource contention, which can degrade overall performance, cause excessive context switching, and even lead to thread starvation or deadlocks. Non members can access from here Effective Parallelism Strategies to Mitigate High CPU Usage in .NET Core We will fix problem occurs due to incorrect use Parallelism in .NE...

Best practice Generic List Filter using Func in C#

  In this Chapter we will learn about Func<x,y> delegate and its real time implementations and will see how we can create centralize functions to filter generic list. Basic Definition Func delegates offer a straightforward approach to defining and utilising methods by passing them as parameters and returning them as results. Func<>  is a delegate type for methods that return a value. we can have up to 16 parameters, with the return type always being the last type parameter. It’s useful for passing methods as arguments or working with lambda expressions in a clean and concise way. Syntax Consider below syntax, it has two parts left and right. Right side of lamba expression is return value and Left side of lamba expression is input parameters. Example:  This is simple code using System; class Program { static void Main () { // A Func delegate that adds two integers Func< int , int , int > add = (x, y) => x + y; int ...