Handling long-running operations in a .NET Background Service

Handling long-running operations in a .NET Background Service

I have seen few articles around about how to execute long-running tasks in a BackgroundService and most of them do the same mistake. The code looks more or less like this: public class MyWorker : BackgroundService { protected override async Task ExecuteAsync(CancellationToken cancellationToken) { while(!cancellationToken.IsCancellationRequested) { await DoSomethingAsync(); } }...

2 minute read
Are design patterns dead? The Singleton problem

Are design patterns dead? The Singleton problem

Today we’ll talk about another Design Pattern: the Singleton. I’m pretty much sure everyone knows what I am talking about, but just to be sure, let’s do a quick recap. The Singleton pattern guarantees that there is only one instance of a class throughout the application. This can be beneficial...

5 minute read
Microservices or Monolith, what to pick?

Microservices or Monolith, what to pick?

Wow, almost 2 months since my last post. I’m really starting to fall behind. And honestly, it would probably have taken even more, if it wasn’t for one of my connections on Linkedin. A few days ago, I got a message from one of my contacts. They wanted a piece...

2 minute read
What does a Compensating Transaction do?

What does a Compensating Transaction do?

Hi All! Today I want to expand a bit the concept we discussed last time, and talk about Compensating Transactions. In simple terms, a Compensating transaction it’s all about reversing the effects of a previous transaction. This is often used in cases where a previous transaction was made in error,...

3 minute read