© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
1 reply
Hugh

✅ Using Dependency Injection, sharing singletons between builders?

I'm not sure if I'm taking a completely off-the-wall approach to this, so please let me know if I should completely restructure here.

I'm currently using a class that implements
IHostedService
IHostedService
for my program, and then that creates two separate
WebApplications
WebApplications
(two because they are listening in different directions, with different CORS settings, and one has a Controller, and the other has a SignalR Hub)

What this means is that I have three different Builders at different parts of my code - one to create the initial program, and then one each for the two WebApplications.

The issue I've hit upon is that I need to share some of the same singletons between these three. Is there a way to do this? Or is there a better way to set up the application across the board?

Thanks
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

Dependency injection
C#CC# / help
6mo ago
✅ Dependency injection
C#CC# / help
2y ago
❔ Dependency Injection
C#CC# / help
3y ago
WPF local: when using Dependency Injection
C#CC# / help
15mo ago