sasadelivery.blogg.se

How to get core out of handle
How to get core out of handle







how to get core out of handle
  1. HOW TO GET CORE OUT OF HANDLE HOW TO
  2. HOW TO GET CORE OUT OF HANDLE CODE

The thing that slows down the process is thread handling. This is way better than before, but it’s not impressive. A drawback here would be an exception handling because when something goes wrong you will get an AggregatedException with possibly multiple exceptions, but you would not know which task caused it. WhenAll is a beautiful creation that waits for tasks with the same type and returns a list of results. Var tasks = userIds.Select(id => client.GetUser(id))

HOW TO GET CORE OUT OF HANDLE CODE

The code can look like this: public async Task> GetUsersInParallel(IEnumerable userIds) Running in parallel is the key here because you can make many requests and use the same time that one request takes. If you look at how requests are executed in time, you will see something like this: Asynchronous means requests will not block the main thread, that can go further with the execution. This is because although it is asynchronous programming, it doesn’t mean requests are done in parallel. public async Task> GetUsersSynchrnously(IEnumerable userIds) Var user = JsonConvert.DeserializeObject(await ()) Īsynchronous programming in C# is very simple, you just use async / await keywords in your methods and magic happens. I wrapped a single call in a UsersClient class: public class UsersClient

how to get core out of handle how to get core out of handle

So the task here is to write a method, that would call this endpoint and fetch 1000 users by their ids as fast as possible.

HOW TO GET CORE OUT OF HANDLE HOW TO

Here is my post on how to build an app and deploy it to Azure: Īnd a post about custom data source in Application Insights: I was also able to debug it remotely and check it’s work in Application Insights. net core app can be deployed and tested in a real hosting environment. I deployed it quickly to Azure using App services and it was ready for testing in less than two hours. It fetches them from plain old MSSQL database. In order to test different methods of handling requests, I created a very simple ASP.Net Core API, that return user by his id. I want to make 1000 requests! How can I make it really fast? Let’s have a look at 4 approaches and compare their speed.









How to get core out of handle