Hello
I am having a problem that i would be really greatful for any direction with.
I have created a vb.net project (windows forms application), and added a new class to it.
The purpose of the class is to keep a single instance of a collection of "Games" in memory. Therefore this class uses the singleton pattern to acheive this. I have put the code below.
When the windows forms application loads, populates this collection with a few games.
This works fine so far.
Here is the problem..
When i add another project to this solution - ie a Web Service for example.
I add a reference for the windows forms application to my Web Service project.
If i start my windows forms application running - then start my web service running, and from the webservice i call the "GamesFactory.GetGames" method - i get back a completely new instance of the Games collection, even though i know one allready exists in memory.
I am not sure how i can force this collection to be a single instance in memory, and retrieve that same instance from othe projects within the solution!
Please Please help
Many Thanks
Darrell
I am having a problem that i would be really greatful for any direction with.
I have created a vb.net project (windows forms application), and added a new class to it.
The purpose of the class is to keep a single instance of a collection of "Games" in memory. Therefore this class uses the singleton pattern to acheive this. I have put the code below.
VB.NET:
Public Class GamesFactory
Shared _Games As List(Of IGames)
Shared Function GetGames() As List(Of IGames)
If _Games Is Nothing Then
_Games = New List(Of IGames)
End If
Return _Games
End Function
Shared Function AddGame(ByVal Game As IGame) As Integer
GetGames().Add(Game)
End Function
End Class
When the windows forms application loads, populates this collection with a few games.
This works fine so far.
Here is the problem..
When i add another project to this solution - ie a Web Service for example.
I add a reference for the windows forms application to my Web Service project.
If i start my windows forms application running - then start my web service running, and from the webservice i call the "GamesFactory.GetGames" method - i get back a completely new instance of the Games collection, even though i know one allready exists in memory.
I am not sure how i can force this collection to be a single instance in memory, and retrieve that same instance from othe projects within the solution!
Please Please help
Many Thanks
Darrell