vendredi 11 mars 2016

How to communicate across projects inside a .NET solution?

I have a .NET Core (UWP solution) which has 3 different projects (let's call them A, B and C).

A and B are Windows Runtime Components, and C is a simple Class Library.

Projects A and B have a reference to the project C.

I would like to access a class from the project C, whose the instance is shared between projects A and B.

I thought to a singleton pattern (of course), using the Lazy method of .NET 4

Problem is that the instance is not the same each time A and B projects access the instance. The Lazy method creates a new instance of the class because it seems not to be previously created. I wonder if I can share a singleton between different projects of a solution. I've read that a project is associated to a process, and each process has its own memory space which cannot be shared. Is there a solution to my issue?

Aucun commentaire:

Enregistrer un commentaire