|
-
December 29th, 2008, 08:41 PM
#2
Re: Help creating interface.
This seems like a very unusually requirement and probably a bad design. If you give some more details I could suggest a better alternative. In the meantime I have a suggestion for adding all instances to a global variable. However, there are 2 major issues with this. Someone could create a local instance of the global object. Also, this would result in major memory leaks if you aren't careful about removing references to unused instances of the objects you are tracking.
Code:
Public Class Tracker
Private Instances As List(Of SpecialClass)
Public Sub Add(ByVal obj As SpecialClass)
Instances.Add(obj)
End Sub
End Class
Public Class SpecialClass
Private Sub New()
End Sub
Public Shared Function GiveMeANewOne(ByVal tracker As Tracker) As SpecialClass
Dim obj As New SpecialClass()
tracker.Add(obj)
Return obj
End Function
End Class
If you implement ths in a dll you should be able to prevent creation of local Trackers. However, you still have the issue of memory leaks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|