© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago
Pan!cKk

Scaling Background Services !

I have a background service that uses Redis as it's main operating database. What this background service do is that on user input (start button event), I store that entity on Redis and the background service keeps fetching these entities and process them (or not) based on different conditions.

What I store on Redis is a list of those entities, so when a new process is requested, a new item is added to that list, and then I fetch that list and process the items within a foreach loop.

It works fine with a single instance, but I am trying to figure out a way on how to make it work with multiple instances.

What I tried so far was adding an new property to that entity, "IsLocked" so when it is fetched, I set that property to "true" so the other one does not process it, and finally I set it to "false". In theory it sounded possible, but the background service is executed every 100ms, what I am assuming that the other instance fetches that list before the other one updates the "IsLocked" property.

I hope I am being clear with my request, but this is my first time trying to working with multiple instances, so be gentle !

Could someone provide me with some helpful resources and tips of what could be a good solution for my case? Or even if I should use a completely different approach !

Thank you in advance :)
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Notifications and Background services
C#CC# / help
2y ago
Background services with parameters
C#CC# / help
4y ago
✅ Should I create single or multiple background services
C#CC# / help
2y ago
WPF Scaling Bug
C#CC# / help
16mo ago