I have a .NET Core (UWP) application that has 3 different projects (let them name A, B and C).
A and B are Windows runtime components, and C is a simple class library.
Projects A and B have a link to project C.
I would like to access the project C class, an instance of which will be shared between projects A and B.
I thought of one template (of course) using the Lazy.NET 4 method
The problem is that the instance is not the same every time projects A and B access the instance. The Lazy method creates a new instance of the class because it does not seem to have been created before. I wonder if I can share one single between different solution projects. I read that the project is associated with a process, and each process has its own memory space that cannot be used. Is there a solution to my problem?
EDIT : Here is my implementation of my HubService class:
private static readonly Lazy<HubService> Lazy = new Lazy<HubService>(() => new HubService(), LazyThreadSafetyMode.ExecutionAndPublication); private HubService() { _asyncQueue = new AsyncQueue<Guid>(); } public static HubService Instance => Lazy.Value;
Also, is it possible to exchange a singleton connection between different assemblies using tools such as Castle Windsor, Ninject, Autofac, or Unity?
source share