Okay I managed to find the answer somewhere. In the Program.cs I needed to add:
builder.Services.AddSingleton<MyService>();
I think every new call created a new instance of the service before I added the line. I could be wrong though.